robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
168 stars 13 forks source link

[BUG] The editor could not be opened due to unexpected error #218

Closed Krata4 closed 4 months ago

Krata4 commented 4 months ago

Describe the bug When I am debugging my project and code stopped with error, first error and file is displayed but after that this error appears:

image

I am running tests which are using datadriver and I am using dynamic loading of resource based on variable. I think this is reason why it is failing: Resource ../Resources/${COMPANY}API.resource

Thanks Daniel for your work Jirka Kratochvil

d-biehl commented 4 months ago

First Thanks!!! for your issue!!!

but sorry, I can't reproduce this error. Normally, if the debugger stops at an error, all variables in the settings/import definition should be resolved, because RobotFramework needs this to load the resources. So in the debugger normally I only get full resolved paths to the files.

Maybe you can give me a little more input, this would help me alot:

Maybe you can create a simple sample project, where I can reproduce it. Or give some code snippets.

Krata4 commented 4 months ago

I will try to create some simple project with reproducing of this issue.

Thanks

Krata4 commented 4 months ago

This is error from console after finish of the debuging:

Traceback (most recent call last): File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\protocol.py", line 254, in done self.send_response(message.seq, message.command, t.result()) ^^^^^^^^^^ File "c:\Users.....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\server.py", line 364, in _evaluate result = Debugger.instance().evaluate(expression, frame_id, context, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\debugger.py", line 1585, in evaluate else evaluate_context.variables._global ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'variables' AttributeError: 'NoneType' object has no attribute 'variables' Traceback (most recent call last): File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\debugger.py", line 1585, in evaluate else evaluate_context.variables._global ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'variables' AttributeError: 'NoneType' object has no attribute 'variables' Traceback (most recent call last): File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\protocol.py", line 254, in done self.send_response(message.seq, message.command, t.result()) ^^^^^^^^^^ File "c:\Users\Z64499668.vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\server.py", line 364, in _evaluate result = Debugger.instance().evaluate(expression, frame_id, context, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\debugger.py", line 1585, in evaluate else evaluate_context.variables._global ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'variables' AttributeError: 'NoneType' object has no attribute 'variables' Traceback (most recent call last): File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\debugger.py", line 1585, in evaluate else evaluate_context.variables._global ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'variables' AttributeError: 'NoneType' object has no attribute 'variables' Traceback (most recent call last): File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\protocol.py", line 254, in done self.send_response(message.seq, message.command, t.result()) ^^^^^^^^^^ File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\server.py", line 364, in _evaluate result = Debugger.instance().evaluate(expression, frame_id, context, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users....vscode\extensions\d-biehl.robotcode-0.74.0\bundled\libs\robotcode\debugger\debugger.py", line 1585, in evaluate else evaluate_context.variables._global ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'variables'

d-biehl commented 4 months ago

is this happens everytime? do you have an example of I get this error?

Krata4 commented 4 months ago

in debug mode only. run tests is without error. I think this is about open file which is via variable ${COMPANY} :-) When I am running tests without debugging the file is not opened therefore no error is appear :-)

d-biehl commented 4 months ago

Ok, I have now investigated this and fixed it. The problem here is actually several problems that interact. But either no one has found them yet or people are simply too lazy to report them. Therefore: Thanks again for reporting.

  1. DataDriver

    DataDriver Library creates virtual test cases when it is executed, but these test cases have no line number, or it is not taken over from the original test case. I have just spoken to the developer of DataDriver and we have created a fix which will be released in the next few days. See here: https://github.com/Snooz82/robotframework-datadriver/pull/94

  2. RobotFramework

    If RobotFramework executes a test case, keyword or so, where the line number is not set internally, i.e. None, it generates an empty string for the line number in the listener (the debugger is nothing other than a listener) instead of also passing None. This rarely happens, but it does occur. The debugger has now misinterpreted this empty string, has taken this value and sent it to VSCode, hence the "Invalid Argument" as shown in the screenshot above In Robot Framework the behavior is fixed from version 7. In RobotCode I have made a few small changes so that it also works with the other Robot versions <7.

    Be patient, the fix for RobotCode is on its way, the fix for DataDriver will be available in the next few days.

And I also fixed the traceback after debugging. Sometimes, especially when exiting, VSCode is too slow or the debugger is too fast (or vice versa) and VSCode still sends commands to the debugger even though it is already finished. And! your variables in the import file names are all ok and can remain as they are.

Snooz82 commented 4 months ago

Fixed with DataDriver 1.11.0

d-biehl commented 4 months ago

Thanks @Snooz82

Krata4 commented 4 months ago

Thanks @Snooz82 @d-biehl