robotframework / RIDE

Test data editor for Robot Framework
Apache License 2.0
957 stars 378 forks source link

Serializing fails when adding import to test suite #2679

Closed JFoederer closed 7 months ago

JFoederer commented 7 months ago

After upgrading to RIDE v2.1dev1 on Windows Python 3.11 I added a new test suite (.robot file) to an existing test suite of mine. When saving the newly added file, I got the failure from the screenshot:

image

The contents shown are the only things added, apart from a single resource import. Removing the import lets me save the file as expected. Re-including any resource or library to the imports causes this failure to occur again. Even when just adding Library string. No additional info shows up in the RIDE or Parser logs.

I failed in trying to create a minimal example. Isolating the file, including sub suites with or without spaces in their names, does not trigger the issue. It is however a persistent issue when adding just this single file to the existing project.

JFoederer commented 7 months ago

The issue may not be related to the specifics of the contents. Could it be that RIDE also saves some other settings during the first save after upgrading to this version? After closing RIDE and adding the import using a text editor I was able to open, run, edit and save the exact file. While attempting some re-opens I did notice that the file explorer in RIDE, which I usually do not have visible, popped up multiple times. First at the bottom left of the main window, later in the upper left. Now that everything settled down there do not seem to be further issues with this.... for now.

HelioGuilherme66 commented 7 months ago

The error comes from the model validation from RF 6.1.1. I now create a file using the RF API.

Will need to see if there is side-effects.

You should try to disable Text Editor plugin, because it may be the culpate of thise validations.

JFoederer commented 7 months ago

Closing the text editor using the cross-symbol on the tab did not work. Disabling it from the plugin menu also failed: image

It is off now, let's see what that does. Syncing between grid- and text editor also still showed some issues before, but that was already the case before 2.1dev1.

JFoederer commented 7 months ago

I now also ran into the issue with the text editor disabled. After adding a list to the variables section.

HelioGuilherme66 commented 7 months ago

I managed to reproduce, but only seen the error in the console. After all, the error is my my modified parser. I need to add protection on that code.

DEBUG: filewriters.py table_sorter [(1, <robotide.lib.robot.parsing.model.TestCaseFileSettingTable object at 0x7f0bf45a5690>), (None, <robotide.lib.robot.parsing.model.VariableTable object at 0x7f0bf45995d0>), (5, <robotide.lib.robot.parsing.model.TestCaseTable object at 0x7f0bf45982d0>)]
Traceback (most recent call last):
  File "/home2/helio/github/RIDE/src/robotide/editor/texteditor.py", line 181, in _on_timer
    self._open_tree_selection_in_editor()
  File "/home2/helio/github/RIDE/src/robotide/editor/texteditor.py", line 228, in _open_tree_selection_in_editor
    self._editor.open(DataFileWrapper(datafile_controller, self.global_settings, self._editor.language))
  File "/home2/helio/github/RIDE/src/robotide/editor/texteditor.py", line 751, in open
    self.source_editor.set_text(self._data.content)
                                ^^^^^^^^^^^^^^^^^^
  File "/home2/helio/github/RIDE/src/robotide/editor/texteditor.py", line 426, in content
    return self._txt_data(self.wrapper_data.data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home2/helio/github/RIDE/src/robotide/editor/texteditor.py", line 430, in _txt_data
    data.save(output=output, fformat='txt', txt_separating_spaces=self._settings.get(TXT_NUM_SPACES, 4),
  File "/home2/helio/github/RIDE/src/robotide/lib/robot/parsing/model.py", line 269, in save
    return DataFileWriter(**options).write(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home2/helio/github/RIDE/src/robotide/lib/robot/writer/datafilewriter.py", line 42, in write
    FileWriter(ctx).write(datafile)
  File "/home2/helio/github/RIDE/src/robotide/lib/robot/writer/filewriters.py", line 72, in write
    sorted_tables = table_sorter(tables)
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home2/helio/github/RIDE/src/robotide/lib/robot/writer/filewriters.py", line 40, in table_sorter
    sorted_result = sorted(sorted_tables)
                    ^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'NoneType' and 'int'