Skip to content

Fix additionalProperties:false enforcement and format validate: crash - #80

Merged
noha merged 1 commit into
masterfrom
fix-additionalproperties-and-format-validate-bugs
Aug 2, 2026
Merged

Fix additionalProperties:false enforcement and format validate: crash#80
noha merged 1 commit into
masterfrom
fix-additionalproperties-and-format-validate-bugs

Conversation

@noha

@noha noha commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@noha
noha merged commit d6ac78c into master Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant