Fix additionalProperties:false enforcement and format validate: crash - #80
Merged
Merged
Conversation
Two bugs found 2026-08-02 via the RecurringEvents schema (schema/recurring-events.schema.json), a real-world consumer with deeply $ref-nested oneOf discriminated unions and explicit type+format string fields: 1. JSONSchemaPatternPropertiesConstraint (the constraint enforcing additionalProperties) only activated when patternProperties was present, even though its validate: logic already handled the no-patternProperties case correctly - a properties-only schema with additionalProperties:false silently accepted extra properties. This is part B of the previously-documented "11er-Bug" (3 testsuite cases); JSONSchemaAdditionalPropertiesCanExistByItselfTests, JSONSchemaAdditionalPropertiesShouldNotLookInApplicatorsTests and JSONSchemaAdditionalPropertiesAllowsASchemaWhichShouldValidateTests now pass for real - their expectedFailures overrides are removed per the project convention of deleting an expectedFailures method once its list is empty. 2. JSONPrimitiveSchema>>validate: called the format class's own class-side validate: with the raw JSON string, a leftover from before JSONSchemaFormatConstraint (Tier G) existed. JSONFormatDateTime/JSONFormatDate/JSONFormatURI's class-side validate: expect an already-converted value (DateAndTime/Date/ZnUrl), so this crashed with a bogus JSONTypeError for every valid date-time/date/uri string whenever type was explicit alongside format - the initial diagnosis blamed oneOf/$ref resolution, but isolating the repro traced it to this single redundant, wrong call; JSONSchemaFormatConstraint's own validateString: already covers this correctly and generically. Removed the redundant call. Added two regression tests to JSONSchemaTests. Raw testsuite sweep: 1020 total, 77 red (down from 80), 0 regressions; JSONSchema-Core-Tests 125/125 green.
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.
Two bugs found 2026-08-02 via the RecurringEvents schema (schema/recurring-events.schema.json), a real-world consumer with deeply $ref-nested oneOf discriminated unions and explicit type+format string fields:
JSONSchemaPatternPropertiesConstraint (the constraint enforcing additionalProperties) only activated when patternProperties was present, even though its validate: logic already handled the no-patternProperties case correctly - a properties-only schema with additionalProperties:false silently accepted extra properties. This is part B of the previously-documented "11er-Bug" (3 testsuite cases); JSONSchemaAdditionalPropertiesCanExistByItselfTests, JSONSchemaAdditionalPropertiesShouldNotLookInApplicatorsTests and JSONSchemaAdditionalPropertiesAllowsASchemaWhichShouldValidateTests now pass for real - their expectedFailures overrides are removed per the project convention of deleting an expectedFailures method once its list is empty.
JSONPrimitiveSchema>>validate: called the format class's own class-side validate: with the raw JSON string, a leftover from before JSONSchemaFormatConstraint (Tier G) existed. JSONFormatDateTime/JSONFormatDate/JSONFormatURI's class-side validate: expect an already-converted value (DateAndTime/Date/ZnUrl), so this crashed with a bogus JSONTypeError for every valid date-time/date/uri string whenever type was explicit alongside format - the initial diagnosis blamed oneOf/$ref resolution, but isolating the repro traced it to this single redundant, wrong call; JSONSchemaFormatConstraint's own validateString: already covers this correctly and generically. Removed the redundant call.
Added two regression tests to JSONSchemaTests. Raw testsuite sweep: 1020 total, 77 red (down from 80), 0 regressions; JSONSchema-Core-Tests 125/125 green.