Skip to content

Commit

Permalink
Improve error prioritisation and messages (#3009)
Browse files Browse the repository at this point in the history
* Add comments to existing tests what the errors are in the chart specification. Relevant as sometimes only one is shown in the resulting error message

* Refactor validate_jsonschema into  smaller functions

* Add new way of prioritizing errors. Group them by path to offending element before passing to SchemaValidationError to allow for better error messages to be created

* Remove whitespaces in blank line

* Make error attribute private

* Add tests for datum and value

* Add type hints to help with refactoring

* Refactor creation of error message as preparation for handling multiple errors

* First draft for showing all distinct errors

* Type hint validate_jsonschema

* Add correct error message to  attribute of SchemaValidationError

* Remove unnecessary deduplication in schemavalidationerror which now already happens in validate_jsonschema

* Remove _get_all_lowest_errors_with_validator

* Add PR to changelog. Only show one line for error message improvements in changelog

* Remove indentation in error messages which had to be removed with inspect.cleandoc. This makes it easier to work on the error messages

* Use f string instead of format

* Reorder methods in calling order

* Refactor _get_message_for_errors

* Improve error messages for multiple errors about the same instance

* Move call of _get_altair_class_for_error into _get_message_for_errors

* Add docstrings

* Minor refactoring

* Format code

* Enumerate error messages. Don't separate by line as unclear how long it should be as this depends on the frontend

* Add more test examples

* Harmonize chart_error_example function names

* Somehow the VL 5.6.1 schema changed slightly. Including the changes here as we upgrade to 5.7 anyway before a release

* Revert "Somehow the VL 5.6.1 schema changed slightly. Including the changes here as we upgrade to 5.7 anyway before a release"

This reverts commit 09805a3.

* Remove # in front of error number

* Add 'Multiple errors were found.' as a first line if multiple errors are found

* Indent error messages from the second line onwards if multiple errors are shown

* Show a maximum of 3 errors

* Some white spaces were removed in a description in the VL 5.6.1 schema. Changes are not relevant as we upgrade to 5.7 anyway. They happened as part of resolving vega/schema #8

* Minor improvements

* Revert minor change

* re-run generate_schema_wrapper.py

* Capitalize bullet points

---------

Co-authored-by: Mattijn van Hoek <[email protected]>
  • Loading branch information
binste and mattijn authored Apr 25, 2023
1 parent 9abc8f0 commit c273c0a
Show file tree
Hide file tree
Showing 4 changed files with 1,131 additions and 378 deletions.
Loading

0 comments on commit c273c0a

Please sign in to comment.