Fix github-workflow schema to avoid ambiguous $ref #5027
Merged
+202
−126
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the
pull_request,pull_request_target, andpushevent types,the schema was declared to both define properties and use a
$refwhich defined properties (
#/definitions/ref).This usage is ambiguous at best, since it's unclear if the properties are
meant to be merged -- which is the intent and AJV's behavior -- or
overridden. These definitions are updated here to avoid using a $ref at
all, and greatly enhance the clarity of their semantics by nesting
oneOfandallOfin a way which better reflects the criteria beingdeclared.
The newly added negative test passes with AJV using the schema in
masterbut fails when run throughpython-jsonschema's toolchain.Specifically, a failure is easy to produce with
With the schema updated to remove the unclear
$refloading, both toolsagree that the negative test input is incorrect.
I have also asked in the official JSON Schema community Slack to see if
anyone from the spec authorship group can confirm that this usage is
ambiguous or invalid.
It's possible that
python-jsonschemais wrong, but I find it less likelygiven AJV's existing reputation for going off-spec in a wide variety of cases.
Update: I got some more info from the JSON Schema spec maintainers.
So anywhere that you see a
$refused with other keywords, rather than the more typical "bare ref", in a Draft 7 schema, that means something is wrong.