robotcode icon indicating copy to clipboard operation
robotcode copied to clipboard

[BUG] Request textDocument/documentSymbol failed.

Open SchnuckySchuster opened this issue 1 year ago • 19 comments

Describe the bug I have the plugin installed and some RobotFramework test files in CucumberFormat open. I'm working under Windows 11.

Steps To Reproduce

  1. Have some RobotFramweork files (*.robot and *.resource) open
  2. Switch between open files
  3. A error message appears

Logs [Error - 09:58:28] Request textDocument/documentSymbol failed. TypeError: Cannot read properties of undefined (reading 'range') at hn (c:\Users\P034724.vscode\extensions\d-biehl.robotcode-0.105.0\out\extension.js:35:71898) at s (c:\Users\P034724.vscode\extensions\d-biehl.robotcode-0.105.0\out\extension.js:35:46654) at Object.yD [as map] (c:\Users\P034724.vscode\extensions\d-biehl.robotcode-0.105.0\out\extension.js:35:46740) at Object.jn [as asSymbolInformations] (c:\Users\P034724.vscode\extensions\d-biehl.robotcode-0.105.0\out\extension.js:35:71541) at c (c:\Users\P034724.vscode\extensions\d-biehl.robotcode-0.105.0\out\extension.js:39:56109) at async uI.provideDocumentSymbols (file:///c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:138:126457) Start analyzing workspace for 4 documents End analyzing workspace for 4 documents took 0.0160 seconds Start collect workspace diagnostic for 4 documents End collect workspace diagnostic for 4 documents took 0.2030 seconds Start analyzing workspace for 4 documents End analyzing workspace for 4 documents took 0.0000 seconds Start collect workspace diagnostic for 4 documents End collect workspace diagnostic for 4 documents took 0.2030 seconds

SchnuckySchuster avatar Jan 07 '25 10:01 SchnuckySchuster

I cannot reproduce this behavior.

What do you mean with CucumberFormat? Maybe you can give some examples?

d-biehl avatar Jan 07 '25 10:01 d-biehl

And some information about your environment would be good, like VSCode Version, Python Version and Robot Framework Version.

d-biehl avatar Jan 07 '25 10:01 d-biehl

I am seeing the same errors.

VSCode version: 1.96.2 Robotcode extension version: 0.105.0 Python: 3.12.5 Robot Framework: 7.1.1

rvankruistum avatar Jan 09 '25 09:01 rvankruistum

Again, I cannot reproduce this bug. It would be really helpfull, if you can provide more informations.

when exactly does this error occur? Where did you find the error? Does a error message popup? In the log files? What is in your files? Do you have maybe a short example?

d-biehl avatar Jan 09 '25 10:01 d-biehl

when exactly does this error occur? When switching between .robot files Where did you find the error? Error popup in the bottom right + output log (see example above) What is in your files? Here is an example (I had to change some stuff to remove company-specific data):

*** Settings ***
Documentation       Test something

Library             RequestsLibrary
Resource            resources/common_keywords.resource

Suite Setup         Create api session    ${URL}/path   session
Test Setup          Run Keywords
...                     Delete All Testdata


*** Test Cases ***
### GET endpoints

User Does Stuff
    User Setup    user
    ${response}=    GET On Session    session    /path
    Status Should Be    200    ${response}
    Should Be Equal As Strings    ${response.json()    {}

Edit: I tested it a bit more, and the error only seems to show up if I have a robot file open with: Test Tags robot:skip (or any other tag)

rvankruistum avatar Jan 09 '25 10:01 rvankruistum

Thanks for the example, but I still cannot reproduce it. Does this happen in earlier versions of RobotCode? DocumentSymbols are related to the Outline View on the right side. Is anything displayed there? Do you have any other extensions related to Robot Framework installed?

d-biehl avatar Jan 09 '25 11:01 d-biehl

Hello,

I don't have exact idea how to reproduce this issue too, but I usually found out the error will popup when I switch my git branch in vscode. here is the screenshot:

image

ghost avatar Jan 09 '25 12:01 ghost

I'm facing the same issue since the latest update of RobotCode VSCode extention to version 0.105.0. The issue does not occur on version 0.104.0.

VS Code shows an error notification when opening or saving a .robot or .resource file: image

Here's error message from the Output Tab of the RobotCode Language Server:

Start collect workspace diagnostic for 2 documents End collect workspace diagnostic for 2 documents took 0.0988 seconds [Error - 11:45:16 AM] Request textDocument/documentSymbol failed. TypeError: Cannot read properties of undefined (reading 'range') at hn (/root/.vscode-server/extensions/d-biehl.robotcode-0.105.0/out/extension.js:35:71898) at s (/root/.vscode-server/extensions/d-biehl.robotcode-0.105.0/out/extension.js:35:46654) at Object.yD [as map] (/root/.vscode-server/extensions/d-biehl.robotcode-0.105.0/out/extension.js:35:46740) at Object.jn [as asSymbolInformations] (/root/.vscode-server/extensions/d-biehl.robotcode-0.105.0/out/extension.js:35:71541) at c (/root/.vscode-server/extensions/d-biehl.robotcode-0.105.0/out/extension.js:39:56109) at async uI.provideDocumentSymbols (file:///vscode/vscode-server/bin/linux-x64/91fbdddc47bc9c09064bf7acf133d22631cbf083/out/vs/workbench/api/node/extensionHostProcess.js:138:126457) Start analyzing workspace for 2 documents End analyzing workspace for 2 documents took 0.0011 seconds

Environment:

  • VSCode version: 1.96.3 (running with a devcontainer inside a local WSL2)
  • Robotcode extension version: 0.105.0
  • Python: 3.11.11
  • Robot Framework: 7.1.1
  • Other extensions: ms-python.python

Even after deactivating all robotcode related settings.json of the user or the workspace and clearing/restarting the RobotCode Language Server, the error remains.

To keep it simple, here's the Outline View of the following minimalistic .robot file, which causes an error when opening/saving it in VSCode:

*** Test Cases ***
Test 1
    No Operation

image

My gut feeling tells me that it has something to do with the *** sections *** used within a .robot or .resource file.

Weinzierleiner avatar Jan 14 '25 12:01 Weinzierleiner

I’ve uploaded a new version; could you try it out and give me some feedback?

d-biehl avatar Jan 15 '25 00:01 d-biehl

I just tried it and it seems to have solved the issue. Thanks!

rvankruistum avatar Jan 15 '25 06:01 rvankruistum

Hi,

I see two different errors types mentioned:

  • textDocument/documentSymbol failed
  • Sending notification workspace/didChangeConfiguration failed

On my side with the new version (RobotCode cache cleared and server restart), il still have the second one. VsCode v1.96.3, RF v7.0, Python 3.12, latest RC extension

The error occurs when I modify a variable in my Settings.json and save the file:

"robotcode.robot.env": { "VALUE": "50" },

[Error - 10:01:09 AM] Sending notification workspace/didChangeConfiguration failed Error: Starting server failed at Lf.$start (c:\Users\myuser.vscode\extensions\d-biehl.robotcode-0.106.0\out\extension.js:41:12225) at async Lf.sendNotification (c:\Users\myuser.vscode\extensions\d-biehl.robotcode-0.106.0\out\extension.js:39:115074) [Error - 10:01:11 AM] Server process exited with code 0.

Thanks !

CedricAudouard avatar Jan 15 '25 09:01 CedricAudouard

I’ve uploaded a new version; could you try it out and give me some feedback?

I can confirm that the issue for the reported error "Request textDocument/documentSymbol failed" is fixed with 0.106.0 - thanks a lot 👍

UPDATE @d-biehl: Rejoiced too soon.. After updating to 0.106.0 I did not encounter the issue, but for some reason, the error appeared again with 0.106.0:

TypeError: Cannot read properties of undefined (reading 'range') at hn (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:71898) at s (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:46654) at Object.yD [as map] (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:46740) at Object.jn [as asSymbolInformations] (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:71541) at c (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:39:56109) at async uI.provideDocumentSymbols (file:///vscode/vscode-server/bin/linux-x64/91fbdddc47bc9c09064bf7acf133d22631cbf083/out/vs/workbench/api/node/extensionHostProcess.js:138:126457)

Weinzierleiner avatar Jan 15 '25 10:01 Weinzierleiner

The workspace/didChangeConfiguration error occurs when you change a setting that requires restarting the language server, while VS Code simultaneously tries to send a notification to the server about the configuration change. This issue will also be resolved in the next release.

d-biehl avatar Jan 15 '25 12:01 d-biehl

This issue has been automatically closed due to a commit message. I believe I have fixed the issues related to this error message. If the problem persists, please feel free to reopen the issue!

d-biehl avatar Jan 15 '25 12:01 d-biehl

Rejoiced too soon.. After updating to 0.106.0 I did not encounter the issue, but for some reason, the error appeared again with 0.106.0:

TypeError: Cannot read properties of undefined (reading 'range')
at hn (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:71898)
at s (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:46654)
at Object.yD [as map] (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:46740)
at Object.jn [as asSymbolInformations] (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:35:71541)
at c (/root/.vscode-server/extensions/d-biehl.robotcode-0.106.0/out/extension.js:39:56109)
at async uI.provideDocumentSymbols (file:///vscode/vscode-server/bin/linux-x64/91fbdddc47bc9c09064bf7acf133d22631cbf083/out/vs/workbench/api/node/extensionHostProcess.js:138:126457)

(I don't have permissions to reopen the ticket.)

Weinzierleiner avatar Jan 16 '25 14:01 Weinzierleiner

@d-biehl Tried just now with latest release 0.106.1 in my case I don't have the warning anymore. I see you suppress UI error notifications, works for me for workspace/didChangeConfiguration error :) Thanks

CedricAudouard avatar Jan 17 '25 06:01 CedricAudouard

For me the issue is unfortunately not fixed with version 0.108.0 and the error notification in VS code saying "Request textDocument/documentSymbol failed" still pops up when a .resource or .robot file is opened in a VS Code tab. This is the output:

TypeError: Cannot read properties of undefined (reading 'range')
    at hn (/root/.vscode-server/extensions/d-biehl.robotcode-0.108.0/out/extension.js:35:71898)
    at s (/root/.vscode-server/extensions/d-biehl.robotcode-0.108.0/out/extension.js:35:46654)
    at Object.yD [as map] (/root/.vscode-server/extensions/d-biehl.robotcode-0.108.0/out/extension.js:35:46740)
    at Object.jn [as asSymbolInformations] (/root/.vscode-server/extensions/d-biehl.robotcode-0.108.0/out/extension.js:35:71541)
    at c (/root/.vscode-server/extensions/d-biehl.robotcode-0.108.0/out/extension.js:39:56109)
    at uI.provideDocumentSymbols (file:///vscode/vscode-server/bin/linux-x64/cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba/out/vs/workbench/api/node/extensionHostProcess.js:138:126457)

What I found out: I can only reproduce the behaviour with the following conditions:

  1. User Settings: "editor.formatOnSave": true and
  2. having a .robotidy configuration within the repo's root folder.

As soon as I delete the .robotidy configuration or comment out its content, clear the cache of RobotCode and restart VS Code, the problem is gone. Vice versa: As soon as I set "editor.formatOnSave" to false and clear the cache of RobotCode and restart VS Code, the issue is gone, too.

Weinzierleiner avatar Jan 30 '25 13:01 Weinzierleiner

@Weinzierleiner what is in your .robotidy file?

d-biehl avatar Feb 05 '25 18:02 d-biehl

@d-biehl I investigated a little more. Here are my conclusions:

  • Within the settings.json of the workspace, "editor.formatOnSave": true must be set
  • install the package robotframework-tidy
  • the error appears without a .robotidy config, too
  • the error appears even with "robotcode.robotidy.enabled": false within the settings.json

I was just able to reproduce it more accurately - here are the steps: Create a test.robot file with the following content:

*** Test Cases ***
test
    test1


*** Keywords ***
test1
    No Operation

With having "editor.formatOnSave": true, hit CTRL+S about five times per second or more often. You'll see that the content gets formated, although "robotcode.robotidy.enabled": false. Then you should see the Error notification.

Weinzierleiner avatar Feb 06 '25 07:02 Weinzierleiner

hopefully I have fixed it now.

I have found some different behaviour in the latest robot version when parsing keywords and testcases with an empty name. In previous versions the name of the corresponding statement instance was None when the name is not given in the source file. Now it is an empty string.

@SchnuckySchuster @rvankruistum @siongwai @Weinzierleiner can you confirm that this error is now fixed?

d-biehl avatar Feb 28 '25 21:02 d-biehl

@d-biehl For me my issue is unfortunately not fixed with 0.109.6. When saving the file or switching the browser tab, this error occurs:

TypeError: Cannot read properties of undefined (reading 'range')
    at hn (c:\Users\user\.vscode\extensions\d-biehl.robotcode-0.109.6\out\extension.js:35:71898)
    at s (c:\Users\user\.vscode\extensions\d-biehl.robotcode-0.109.6\out\extension.js:35:46654)
    at Object.bD [as map] (c:\Users\user\.vscode\extensions\d-biehl.robotcode-0.109.6\out\extension.js:35:46740)
    at Object.jn [as asSymbolInformations] (c:\Users\user\.vscode\extensions\d-biehl.robotcode-0.109.6\out\extension.js:35:71541)
    at c (c:\Users\user\.vscode\extensions\d-biehl.robotcode-0.109.6\out\extension.js:39:56109)
    at LC.provideDocumentSymbols (file:///c:/Users/user/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:135:126795)

Weinzierleiner avatar Mar 03 '25 06:03 Weinzierleiner

Same with @Weinzierleiner

brt-yilmaz avatar Mar 06 '25 12:03 brt-yilmaz

tried a little bit, now I can reproduce it...

d-biehl avatar Mar 06 '25 14:03 d-biehl

@Weinzierleiner @brt-yilmaz and the others can you try again?

d-biehl avatar Mar 06 '25 23:03 d-biehl

@d-biehl That looks very promising, can't reproduce it anymore! Thank you very much :)

Weinzierleiner avatar Mar 07 '25 06:03 Weinzierleiner

same as @Weinzierleiner 💯

brt-yilmaz avatar Mar 07 '25 08:03 brt-yilmaz