Clarify when Criterion context is required#499
Open
char0n wants to merge 1 commit into
Open
Conversation
The `context` field said "If `type` is specified, then the `context` MUST be provided", which contradicts `type: simple`: a simple condition embeds its runtime expression directly in `condition` and has no separate context to apply anything to, yet an explicit `type: simple` would demand a `context`. Scope the requirement to the condition types that apply a pattern/query to a context (`regex`, `jsonpath`, `xpath`), matching the existing "For regex or JSONPath, the `type` and `context` MUST be specified" sentence and the Simple Condition example.
f314b6e to
a52cd64
Compare
ndenny
approved these changes
Jul 8, 2026
frankkilcommins
approved these changes
Jul 8, 2026
frankkilcommins
left a comment
Collaborator
There was a problem hiding this comment.
LGTM - reviewed in spec meeting
Collaborator
|
@char0n could you review the JSON Schema too as I believe it's contradictory and sets context as dependentRequired if type is specified (and not only when the value of type is one of the three that we expect context to be provided). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
In the Criterion Object section, the
contextfield description states:Combined with the
typefield's rule:these create an unintended, contradictory edge case: if an author writes
type: simpleexplicitly, the first clause demands thatcontextMUST be provided — but asimplecondition embeds its runtime expression directly in theconditionstring (e.g.condition: $statusCode == 200) and has no separate context to apply anything to. So the MUST-clause is meaningless (and impossible to satisfy usefully) forsimple.The spec's own Simple Condition Example confirms
simpleneeds no context:(no
contextfield present).The requirement is clearly intended to apply only to the condition types that apply a pattern/query to a context —
regex,jsonpath,xpath— which is already stated separately in theconditionfield description:The four flavors differ exactly here:
simpleembeds runtime expressions inside the condition, whereasregex/jsonpath/xpathapply their pattern/query to a context defined by a runtime expression.Fix
Scope the
contextrequirement toregex/jsonpath/xpath:This removes the
type: simplecontradiction, aligns with the existing "For regex or JSONPath, thetypeandcontextMUST be specified" sentence, and preserves the original example.This is a meaning-preserving editorial clarification (patch-eligible), targeting
v1.1-devas the earliest active branch where it is relevant.