Skip to content
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

Validation fuzz #108

Open
martinschorb opened this issue Jun 16, 2023 · 5 comments
Open

Validation fuzz #108

martinschorb opened this issue Jun 16, 2023 · 5 comments

Comments

@martinschorb
Copy link
Contributor

Hi,

I have some trouble with one of my projects and I try to find out what went wrong, as I only used mobie-python to generate it and it now does not validate any longer.

One big issue is that the output of the validation is not very helpful. It spits out the entire schema cluttering the STDOUT and throws an error only stating what went wrong. But is missing the crucial information where (which view/source etc.) the error occurs.

File ".../jsonschema/validators.py", line 1121, in validate
    raise error
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('name' was unexpected)

Failed validating 'additionalProperties' in schema['properties']['views']['properties']['default']:
    {'$id': 'https://raw.githubusercontent.com/mobie/mobie.github.io/master/schema/view.schema.json',
     '$schema': 'http://json-schema.org/draft-07/schema',
     'additionalProperties': False,
     'definitions': {'additionalTables': {'description': 'Additional '
                                                         'tables to load '
                                                         'for this '
                                                         'display. This '
                                                         'only needs to be '
...

and hundreds of more lines of schema.

Is it possible to change the output such that it provides clues on where the problem is (i.e. where this suspicious extra name can be found?

@constantinpape
Copy link
Contributor

These error messages are generated by the jsonschema library: https://github.com/python-jsonschema/jsonschema
So I only have limited control over the validation error options. I haven't really looked into whether there they provide a way to simplify the validation messages. If you find one I am happy to adopt it here. If not you would need to raise the issue in the jsonschema repo.

@martinschorb
Copy link
Contributor Author

makes sense.
When you know what to look for (this information On instance['views']['default']:) You can find it.
Can a JSON schema be nested (pulling content from other files)? Then maybe it would not display everything but only the relevant part of the schema... (like only from transformedGrid instead of the whole view schema)

@martinschorb
Copy link
Contributor Author

and to complicate things, it seems that the CLI calls for mobie-python don´t pipe their STDOUT.

mobie.validate_project -i data > val.log

produces an empty file and still spits out everything.

@constantinpape
Copy link
Contributor

produces an empty file and still spits out everything.

You have to pipe all output:

mobie.validate_project -i data > val.log 2>&1

(This writes both the output from std:out and std:err to the same stream)

@constantinpape
Copy link
Contributor

Can a JSON schema be nested (pulling content from other files)? Then maybe it would not display everything but only the relevant part of the schema...

Yes, that should in principle be possible and would make sense to implement. (I am personally not able to do this in the foreseeable future, but would be happy to provide pointers if you want to give it a try).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants