Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Request textDocument/documentSymbol failed. #377

Open
SchnuckySchuster opened this issue Jan 7, 2025 · 19 comments
Open

[BUG] Request textDocument/documentSymbol failed. #377

SchnuckySchuster opened this issue Jan 7, 2025 · 19 comments
Labels
bug Something isn't working

Comments

@SchnuckySchuster
Copy link

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 SchnuckySchuster added the bug Something isn't working label Jan 7, 2025
@d-biehl
Copy link
Member

d-biehl commented Jan 7, 2025

I cannot reproduce this behavior.

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

@d-biehl
Copy link
Member

d-biehl commented Jan 7, 2025

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

@rvankruistum
Copy link

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

@d-biehl
Copy link
Member

d-biehl commented Jan 9, 2025

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?

@rvankruistum
Copy link

rvankruistum commented Jan 9, 2025

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)

@d-biehl
Copy link
Member

d-biehl commented Jan 9, 2025

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?

@siongwai
Copy link

siongwai commented Jan 9, 2025

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

@Weinzierleiner
Copy link

Weinzierleiner commented Jan 14, 2025

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.

@d-biehl
Copy link
Member

d-biehl commented Jan 15, 2025

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

@rvankruistum
Copy link

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

@CedricAudouard
Copy link

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 !

@Weinzierleiner
Copy link

Weinzierleiner commented Jan 15, 2025

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)

@d-biehl
Copy link
Member

d-biehl commented Jan 15, 2025

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
Copy link
Member

d-biehl commented Jan 15, 2025

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!

@Weinzierleiner
Copy link

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.)

@d-biehl d-biehl reopened this Jan 16, 2025
@CedricAudouard
Copy link

@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

@Weinzierleiner
Copy link

Weinzierleiner commented Jan 30, 2025

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.

@d-biehl
Copy link
Member

d-biehl commented Feb 5, 2025

@Weinzierleiner what is in your .robotidy file?

@Weinzierleiner
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants