Repository navigation
Fix spurious additionalProperties leaf over a declared member's own failure (#175) - #176
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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 #175
A closed object (
additionalProperties: false) whose declared member fails its own subschema received an extraadditionalPropertiesviolation of the parent over the member's own failure. The verdict never moved; the reader was told to delete a member that exists.Cause
The backend marks a member as evaluated only when the
propertieskeyword passes (PropertiesKeyword::validate()callsaddCheckedProperties()on the success path alone). A declared member failing its own subschema therefore still counts as unchecked whenadditionalPropertiesruns, andfalsereports it as additional.Fix
SchemaValidator::leaf()drops such a leaf: a member the siblingpropertiesmap declares, or one of itspatternPropertiespatterns matches (same regex semantics as the backend'sHelper::patternToRegex), is not additional. An undeclared member keeps its leaf; a member failing the object form ofadditionalPropertieskeeps its leaf — there the backend itself judges the flagged members against the added schema, so what it reports there is real.Repro (from the issue)
{"a":[]}against a closed object withproperties.a: {type: array, minItems: 1}— before:$.a minItemsand a spurious$ additionalProperties; after: the member's failure only.{"a":[],"b":1}— the genuine$ additionalPropertiesforbsurvives.Tests
SchemaValidatorTest::closedObjectDoesNotReportItsDeclaredMemberAsAdditional()— the three bodies underfailures(), thepatternProperties-declared shape, nested closed objects, and the untouched object form.ContractTestcounts updated where they pinned the spurious leaf at every depth of a recursive tree (#181 was reached through those counts, response side included).Gates
composer buildgreen (validate, normalize, require-checker, cs, psalm, 969 tests).composer mutation— covered-code MSI 92%, the escaped set unchanged; every mutant of the new filter is killed by the new test.composer rectorreports one pre-existing complaint on master itself (RepeatedOrEqualToInArrayRectoron a dependency-diff); not addressed here to keep the PR scoped.Corpus
bin/record-openapi-corpus --checkis already stale on master (patternLabelscases; the generator's zoo drifted from the fixture). Verdicts do not move in this change, so re-recording stays outside this PR.