Skip to content

All irrelevant errors are not silenced when parsing reStructuredText data #4086

Closed

Description

@hidmic

Bug description

When processing an ReST file that bears code blocks and csv-table directives, ReST parsing fails if their :file: paths cannot be found by robot.

Steps to reproduce

  1. Paste the following to a test.rst file:
    .. code-block:: robotframework
    
        *** Test Cases ***
        Dummy Test
             No Operation
    
    .. csv-table:: will cause an error
         :file: not/a/real/path/yet.csv 
  2. Run it:
    robot test.rst
Expected Result
==============================================================================
Test                                                                          
==============================================================================
Dummy Test                                                            | PASS |
------------------------------------------------------------------------------
Test                                                                  | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Actual Result
[ ERROR ] Unexpected error: SystemMessage: /home/michel/VirtualEnvs/test.rst:7: (SEVERE/4) Problems with "csv-table" directive path:
[Errno 2] No such file or directory: 'not/a/real/path.csv'.

Activity

  1. hidmic commented on Sep 14, 2021

    @hidmic
    Author

    The issue here is that RobotFramework parses the entire ReST document, even though it ignores everything but robotframework code blocks (see here). This has caused problems in the past already (#2093), which were mitigated to some extent (#2152). This is not enough for csv-table (see here).

    IMHO the solution is to make RobotFramework parse what it needs and only what it needs from ReST files, and ignore everything else.

  2. pekkaklarck commented on Sep 14, 2021

    @pekkaklarck
    Member

    Sounds good to me. Do you have any other examples of constructs that cause errors than csv-table?

    The main question here is that do we consider this a bug that should still be fixed in RF 4.1.2 or can it wait for RF 5.0. The former would mean the fix is out soon but it has some drawbacks:

    • RF 4.1.x releases still need to support Python 2 but the fix seems to work only with Python 3. Making it Python 2 compatible is probably easy, but I'm still not sure is it worth the effort.
    • We want bug fix releases to be as stable as possible. This change would thus need to be tested with various docutils versions to make sure we aren't using an unstable API. With major releases like RF 5.0 this is easier because we have longer pre-release period and possible problems can also be fixed in future bug fix releases. RF 4.1.2 is planned to be the last RF 4.1.x release and I didn't want to create 4.1.3 to fix possible problems caused by this.
  3. hidmic commented on Sep 14, 2021

    @hidmic
    Author

    Sounds good to me. Do you have any other examples of constructs that cause errors than csv-table?

    I don't have too many examples. Taking a quick look at docutils, the figure directive may fail similarly in some circumstances.

    RF 4.1.x releases still need to support Python 2 but the fix seems to work only with Python 3. Making it Python 2 compatible is probably easy, but I'm still not sure is it worth the effort.

    Hmm, yeah. If it's just the __wrapped__ attribute of functools wrapped function, that can be fixed.

    This change would thus need to be tested with various docutils versions to make sure we aren't using an unstable API.

    Good point. From what I can see in https://github.com/docutils-mirror/docutils, the docutils.parsers.rst.directives.directive function has been around since docutils inception and the docutils.parsers.rst.roles.role function has been around since docutils ~0.3. What could have changed is the use docutils makes of them and on which the fix relies on to be a fix. That I haven't checked.

    Ultimately, it's fine if you're wary about potential breakage and you'd rather wait till the next major release. How far are we? I do need the fix 😅

  4. pekkaklarck commented on Sep 14, 2021

    @pekkaklarck
    Member

    I'm fine adding this to RF 4.1.2 if:

    • The code is Python 2 compatible. __wrapped__ seems to be the only problem and that ought to be easy to fix. I added a comment to the PR about that.
    • The fix is tested with different docutils versions. Probably testing with 0.9, the lowest we support, and whatever is the latest version is enough. Would be good to test both with Python 2 and 3 on both of those.
  5. hidmic commented on Sep 14, 2021

    @hidmic
    Author

    The fix is tested with different docutils versions. Probably testing with 0.9, the lowest we support, and whatever is the latest version is enough. Would be good to test both with Python 2 and 3 on both of those.

    Do you happen to have some CI workflows for that?

  6. pekkaklarck commented on Sep 15, 2021

    @pekkaklarck
    Member

    We test with Python 2 and 3 on CI but I think they use the latest docutils. It's probably a lot easier to pip install different versions locally than configuring CI. That said, one Python 3 version on CI using oldest supported docutils while others use the latest could be a good idea in general.

  7. added this to the v4.1.2 milestone on Sep 20, 2021
  8. changed the title [-]ReST `csv-table` directive may cause parsing errors[/-] [+]All irrelevant errors are not silenced when parsing reStructuredText data[/+] on Sep 20, 2021
  9. added a commit that references this issue on Sep 20, 2021
    33ee46d
  10. added
    acknowledge
    on Sep 20, 2021
  11. pekkaklarck commented on Sep 20, 2021

    @pekkaklarck
    Member

    I tested this locally with different docutils and Python versions. I noticed docutils 0.9 didn't work with Python 3, but that same problem occurred also without these changes. Both the old code and the new code worked with docutils 0.10 so everything ought to be fine. With Python 2.7 also docutils 0.9 was fine.

  12. hidmic commented on Sep 20, 2021

    @hidmic
    Author

    @pekkaklarck at last, will this go into a 4.1.2 release or will it hold for the 5.0.0 bump?

  13. pekkaklarck commented on Sep 21, 2021

    @pekkaklarck
    Member

    I considered this a bug fix, and relatively safe, so it's in RF 4.1.2.

  14. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgepriority: mediumrc 1

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions