Skip to content

SDK allows required fields that don't exist #34

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

Open
fdrozdowski opened this issue Feb 25, 2020 · 3 comments
Open

SDK allows required fields that don't exist #34

fdrozdowski opened this issue Feb 25, 2020 · 3 comments

Comments

@fdrozdowski
Copy link
Contributor

While iterating on my plugin, I ended up deleting a field that was still referenced in the 'required' section:

"virtualSourceDefinition": {

"type": "object",

"additionalProperties" : false,

"required": [ "mountLocation" ],

"properties" : {

"name": {

"type": "string",

"prettyName": "Container Name",

"description": "Name to use for container, defaults to random name"

}

}

},

This later caused a confusing UI error by stating that the field was required even though it didn't show up in the UI. This should be caught as part of build phase validation.

┆Issue is synchronized with this Jira Bug by Unito

@fdrozdowski
Copy link
Contributor Author

➤ Ravi Mukkamala commented:

schema file validation is missing in dvp and is being added as part of PYT-335

@fdrozdowski
Copy link
Contributor Author

➤ Ravi Mukkamala commented:

Schema validation uses the schema definitions to validate the given json data instance. In this case, if required fields are not present, they are detected and reported. However, using metaschema file (from json-schema.org) as the schema file and plugin schema json as the instance to validate (and make sure its a valid json), required fields validation cannot be achieved. Reason - metaschema defines "required" to be a string array and validation does ensure it is a string array if that property is defined in plugin schema file. However, validator code in jsonschema package does not look at the "instance" which is the plugin schema object and enforce/validate that all required fields are present in the "properties". Unless we write custom schema walker to do this, most or all the scheme validation tools did not detect this scenario where a property in required fields is not defined at all. This is a link that discusses a similar issue - json-schema-org/json-schema-spec#659

@fdrozdowski
Copy link
Contributor Author

➤ Ravi Mukkamala commented:

Once the issue is fixed, test_schema_validator.py - test_missing_required_field should be enabled again.

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

No branches or pull requests

1 participant