Repository navigation
Pointed body schema diagnostics for contradictory schemas and Ajv refusals (#861) - #871
Merged
Merged
Conversation
…als (#861) Item 8 of #861: a schema the profile admitted but Ajv strict mode refused surfaced as a truncated "refused by the JSON Schema 2020-12 validator" message with no pointer. The profile walk now refuses, with a JSON pointer and a hint, profile keywords combined into a mistake: - a properties name also matched by a patternProperties pattern (the one strict-mode refusal reachable under the current Ajv options); - a required name that additionalProperties: false forbids; - a type-specific keyword beside a type it cannot apply to; - a const value or enum entry outside the declared type (never echoed); - items: false with minItems past prefixItems. Anything Ajv still refuses goes through bodySchemaRefusal: the pointer comes from Ajv's meta-schema instancePath or its message path (else the root), and its wording is redacted (quoted text, URLs and # references elided, control characters replaced, length capped). An unresolvable $ref is never echoed. The core package's unpacked budget rises from 3460 to 3470 KiB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #861 item 8. Ajv strict-mode refusals no longer surface as a truncated generic message. Every refusal is now a profile diagnostic,
Body schema <pointer>: <problem>, with a hint.Behaviour change: stricter
With the current Ajv options, Ajv itself refused only the
properties/patternPropertiesoverlap. The other conditions below used to compile silently even though no request could satisfy them, or the keyword could never apply. They are now refused at load:propertiesname that apatternPropertiespattern on the same schema also matches (this replaces the raw Ajv message).requiredname forbidden byadditionalProperties: false, so no object could ever pass.typeit cannot apply to, such asminLengthonnumber.constvalue or anenumentry not of the declaredtype. The value is never echoed.items: falsewith aminItemslarger thanprefixItemsallows.Ordinary JSON Schema still compiles: keywords with no
type, open tuples, andrequiredwithoutadditionalProperties: false.Any remaining Ajv compile error goes through
bodySchemaRefusal:/.$refgets a fixed message.#references are removed, control characters are replaced, and the text is capped at 160 characters.Evidence (macOS, Node 26)
npm test: 1128/1128.npm run verifyandnpm run test:packagepass.assertBodySchemaandcompileBodySchemamust give identical messages for each.$refURL with credentials.Docs: docs/HTTP.md profile section and
RIM-BODY-SCHEMA-001.🤖 Generated with Claude Code