-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add line numbers to xml validation errors #630
Add line numbers to xml validation errors #630
Conversation
c31713d
to
5cab919
Compare
When researching possibilities for this, I thought I had found a simple solution with
However, after implementing this vulture complained that using lxml.etree is not safe anymore. It would have also required schemas to be loaded in a different way, which would have resulted in a bigger refactor. So the solution in this PR is best I could come up with without refactoring things too much. |
5cab919
to
6c6108e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work putting the line numbers there ^^ Much appreciated.
The API error responses are quite well standardized (since #433), although the validation errors were not following it. The detail
field is always a str
, following the JSON Problem Details specification https://www.rfc-editor.org/rfc/rfc7807. It would be nice to stick with it.
Would it make sense to change it in this PR, as you are already proposing a change to the validation error message?
This makes the error messages slightly more descriptive. Also this enables the validator to parse all the errors from the file at once.
6c6108e
to
2ce8086
Compare
Ok, I altered the new functionality slightly so it collects the error messages and concatenates them in the same string of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Description
Before this PR, validation error reasons when validating an XML file would be something:
Unexpected child with tag 'BAD_ELEMENT' at position 2.
This PR makes those more understandable so they'd instead come out as:
Unexpected child with tag 'BAD_ELEMENT' at line 34.
Also the changes made here enable the validator to find all the errors from the file at once.
Related issues
Fixes #91
Type of change
Changes Made
Testing
Mentions