Fix: select matching deprecated alternative in anyOf/oneOf (#304)#343
Open
ATKasem wants to merge 1 commit into
Open
Fix: select matching deprecated alternative in anyOf/oneOf (#304)#343ATKasem wants to merge 1 commit into
ATKasem wants to merge 1 commit into
Conversation
A deprecation notice is advisory, not a validation failure, but hasProblems() counted it like any other problem. So a deprecated branch of an anyOf/oneOf that actually matched the value was treated as a non-match, and a non-matching sibling was reported instead (e.g. a const branch's 'Value is not accepted' message). The const case happened to work only because enumValueMatch is a separate tiebreaker; a pattern branch had no such luck. Exclude deprecation problems from hasProblems() so match selection ignores them. The deprecation diagnostic is still reported. Fixes microsoft#304
ATKasem
force-pushed
the
fix/anyof-deprecated-match
branch
from
July 17, 2026 19:43
ef9972b to
9f5eee1
Compare
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.
Fixes #304.
In an
anyOf/oneOf, a branch that actually matches the value but is markeddeprecatedwas treated as a non-match, so a non-matching sibling got reported instead. With the schema from the issue,"text value"matches thepatternbranch, but the hover/validation showedValue is not accepted. Valid values: "unused literal".instead ofValue is deprecated.The cause is that the deprecation notice is pushed as a problem, and
ValidationResult.hasProblems()counted it like a validation error when selecting the best alternative. Theconstcase in the issue only worked by luck —enumValueMatchis a separate tiebreaker incompare(); apatternbranch has nothing equivalent, so the deprecated-but-matching branch lost.Fix: exclude deprecation problems from
hasProblems()(they're advisory,severity: Warning,code: ErrorCode.Deprecated). Match selection now ignores them, while the deprecation diagnostic itself is still reported.Added a test in
parser.test.tscovering the issue's schema (matching value →Deprecated; non-matching value → the non-match error, unchanged). Fullparser.test.jspasses;jsonSchemaTestSuitefailure count is unchanged frommainon my machine (pre-existing URN cases).