-
Notifications
You must be signed in to change notification settings - Fork 135
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
Metaschema: error reporting is difficult to understand #1021
Comments
Also cc: @rmouritzen-splunk |
The change mentioned was done to make the metaschema more accurate, not more readable. Prior to the change, it was allowing extra properties in certain cases. Changing the metaschema back would be a regression. About the error message, this is the error messages coming from the The Paths forwards:
Suggestions are welcome. I changed this from a bug to an enhancement since the incorrect JSON is properly being flagged as an error, even though the error message isn't pointing to the root problem. |
Also, the rule for Primary and Required can only go in one direction without it being a breaking change: |
Thanks for clarifying the intent! I don't think we should change it back.
I categorized it as a bug because I consider the ability of the validator to guide folks to the root of the problem an important part of what it does. In the previous version, using the same reproduction steps it would flag the problem as being with the All that said, the label probably doesn't matter all that much.
As I recall that was the reason I tried this "redefinition" strategy with ocsf-schema/metaschema/event.schema.json Lines 12 to 19 in 2707492
object unconstrained.
But maybe there's a better way? If worst comes to worst, I would trade the duplication for the error messages, personally. With any luck, the validator should be helpful in flagging issues for schema developers far more often than we modify the metaschema. |
If this is problematic for your use-case, we can add an explicit check Python code. There are plenty of those already. These checks happen in addition to the metaschema JSON Schema validation (as you may know), so there's no reason we can't do both.
Edit: I'll play with this today, trying the Alan's solution and anything else I can think of. |
@alanisaac: Your PR does the trick. I say we use it. |
Background
With the changes in 3c7ca92, the metaschema was updated to refactor it and make it a bit easier to read. However, this had the side effect of making the error messages more difficult to understand.
To Reproduce
Take the existing schema. Find an event with any attribute that is marked
group: primary
and update it so that it also hasrequirement: optional
, which is not allowed. Run the validator over the schema, and you will see a message like the following:This error message does not point to the issue with the schema.
Notes
I believe this is occurring because the
anyOf
constraint in the event metaschema is not matching the common event schema"$ref": "common-event-object.schema.json"
. Since it does not match, that entire component of the schema is thrown out, and then all attributes from it are treated asunevaluated
.The text was updated successfully, but these errors were encountered: