You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support warnings, not only errors, in parsing model #5210
The parsing model supports setting errors for individual tokens, but there are two problems with the current approach:
Errors (typically syntax errors) aren't separated from warnings (typically deprecations). This caused a problem when deprecating singular section headers (Loudly deprecate singular section headers #4432) and the code reporting the warning as part of execution needed to know what errors can occur in different contexts to handle the problem. With the planned deprecation of the pipe-separated format (Deprecate pipe-separated format #5203) this is likely even a bigger problem, because there's no single context where pipes can be used.
It isn't easy to recognize if the same error/warning occurs multiple times in same file. This requires comparing messages, but because they typically contain some variables parts, they cannot be compared directly. Searching for a certain sub-string is also problematic, because error messages can change.
My proposal for solving both of the above problems is adding new errno attribute to to the Token objects with the following semantics:
errno is an integer representing an error code.
Each error and warning has a different code.
Codes have constant names like ERR_SINGULAR_HEADER_DEPRECATED stored as attributes of the Token class.
Errors and warnings have different ranges so that it is easy to separate them. We could, for example, use negative values with warnings and positive with errors. Zero would mean no error/warning.
After looking into this, I wanted to know if it makes sense to introduce a data model for errors/warnings.
@dataclass(frozen=True)classInvalidTokenError:
level: ErrorKindcode: ErrorCodemessage: str|None=Noneis_fatal: bool=False# I added this to control when the robot should throw a hard error. I'm not fully aware of all the use cases, but it seems that in some cases, `DataError` is thrown immediately.
This way, we don't need specific ranges for errors/warnings.
I came across this issue related to the exit-on-error thingy (see, issue).
I'm unsure if it's applicable, but I thought we could leverage this new functionality to tackle at least some part of the exit-on-error problem space (meaning parsing). If a user sets the exit-on-error option, could we pass the info to the parser and raise a hard error in case a parsing error occurs? I understand there are subtleties when it comes to exit-on-error, and how to tackle that in different scenarios might not be trivial.
The deprecation of the pipe-separated format (#5203) that would need this enhancement has been moved to RF 7.3. Because this enhancement doesn't have any other usages right now, it's best to move this as well.
There's a new usage for reporting parsing time warnings: reporting deprecated translations (#5668). We could handle deprecated section headers using same kludge we used when deprecating singular section headers (#4432), but handling deprecated settings would require much more kludges. This issue was originally created because deprecating singular headers turned out to be somewhat complicated, and I believe it's now best to implement this.
Although this issue is totally valid, I think the design I proposed in the description is overly complicated. There could be some benefits with adding errno that identifies errors and warnings, but maintaining and documenting these error codes would add extra work. At least with the current use case just separating warnings and errors is enough, and I believe that covers also future usages. If we in the future need something more complicated, we can enhance error/warning reporting further when we know what we actually need. Designing and implementing something complicated now is most likely YAGNI. In the worst the complicated design wouldn't anyway solve the future needs and we needed anyway make changes.
What I wrote above about the design I proposed matches equally well to the draft PR #5241. It has even more complicated design where error messages are turned into objects that have the error code, error kind (i.e. severity) and the actual error message as attributes. I don't see concrete needs for such functionality, and that change would also break IDE plugins, linters, formatters and other tools that use the parsing API.
After thinking this a bit more and looking at the related code, I believe the best way to implement this is adding new Token.warning and Statement.warnings attributes that work exactly the same way as the current Token.error and Statement.errors. When transforming the parsing model to an executable model, we could then report warnings and errors separately. External tools working with the model could do the same, and older external tools that don't know about these new attributes would just ignore them.
My next steps related to this are:
Start a discussion about this on the #devel channel on our Slack. I want to get opinions from others, especially from those developing tools that work with the parsing model. Comments are obviously appreciated here as well.
changed the title [-]Enhance reporting errors and warnings in parsing model tokens[/-][+]Support warnings, not only errors, in parsing model[/+]on May 7, 2026
I created a prototype earlier, but it didn't work as well as I hoped. We now want to get RF 7.5 out and I decided to move this issue to RF 7.6 instead of trying to implement it. This means that we can add translation deprecation system (#5668) so that old and new terms work, but there will never be actual deprecation warnings. That doesn't matter in practice, because the plan was to start emitting deprecation warnings earliest in RF 7.6. To make that happen, we then really need to get this issue done. I raised the priority and effort estimation accordingly.
Activity
mikeleppane commentedon Oct 1, 2024
Hey! If it is okay, I would be interested in looking at this.
mikeleppane commentedon Oct 1, 2024
After looking into this, I wanted to know if it makes sense to introduce a data model for errors/warnings.
This way, we don't need specific ranges for errors/warnings.
mikeleppane commentedon Oct 2, 2024
This is just playing around with the code. Trying to find the best solution. Here's a one proposal:
It allows the Token type to handle its reporting. I think this
raise_on_invalid_headerdoes not belong to theErrorReportertype.mikeleppane commentedon Oct 16, 2024
I've had a working implementation ready locally for some time now. Should I create a pull request, or should we discuss the implementation approach?
pekkaklarck commentedon Oct 16, 2024
It's probably easiest if you create a PR, you can make it draft, so that it's easier to see the code.
mikeleppane commentedon Oct 19, 2024
I came across this issue related to the
exit-on-errorthingy (see, issue).I'm unsure if it's applicable, but I thought we could leverage this new functionality to tackle at least some part of the
exit-on-errorproblem space (meaning parsing). If a user sets theexit-on-erroroption, could we pass the info to the parser and raise a hard error in case a parsing error occurs? I understand there are subtleties when it comes toexit-on-error, and how to tackle that in different scenarios might not be trivial.I could investigate this if that's okay.
pekkaklarck commentedon Dec 30, 2024
The deprecation of the pipe-separated format (#5203) that would need this enhancement has been moved to RF 7.3. Because this enhancement doesn't have any other usages right now, it's best to move this as well.
2 remaining items
Deprecation support to `Languages`
pekkaklarck commentedon May 7, 2026
There's a new usage for reporting parsing time warnings: reporting deprecated translations (#5668). We could handle deprecated section headers using same kludge we used when deprecating singular section headers (#4432), but handling deprecated settings would require much more kludges. This issue was originally created because deprecating singular headers turned out to be somewhat complicated, and I believe it's now best to implement this.
Although this issue is totally valid, I think the design I proposed in the description is overly complicated. There could be some benefits with adding
errnothat identifies errors and warnings, but maintaining and documenting these error codes would add extra work. At least with the current use case just separating warnings and errors is enough, and I believe that covers also future usages. If we in the future need something more complicated, we can enhance error/warning reporting further when we know what we actually need. Designing and implementing something complicated now is most likely YAGNI. In the worst the complicated design wouldn't anyway solve the future needs and we needed anyway make changes.What I wrote above about the design I proposed matches equally well to the draft PR #5241. It has even more complicated design where error messages are turned into objects that have the error code, error kind (i.e. severity) and the actual error message as attributes. I don't see concrete needs for such functionality, and that change would also break IDE plugins, linters, formatters and other tools that use the parsing API.
pekkaklarck commentedon May 7, 2026
After thinking this a bit more and looking at the related code, I believe the best way to implement this is adding new
Token.warningandStatement.warningsattributes that work exactly the same way as the currentToken.errorandStatement.errors. When transforming the parsing model to an executable model, we could then report warnings and errors separately. External tools working with the model could do the same, and older external tools that don't know about these new attributes would just ignore them.My next steps related to this are:
[-]Enhance reporting errors and warnings in parsing model tokens[/-][+]Support warnings, not only errors, in parsing model[/+]pekkaklarck commentedon Jul 16, 2026
I created a prototype earlier, but it didn't work as well as I hoped. We now want to get RF 7.5 out and I decided to move this issue to RF 7.6 instead of trying to implement it. This means that we can add translation deprecation system (#5668) so that old and new terms work, but there will never be actual deprecation warnings. That doesn't matter in practice, because the plan was to start emitting deprecation warnings earliest in RF 7.6. To make that happen, we then really need to get this issue done. I raised the priority and effort estimation accordingly.