Skip to content

formatAssertion:false hides malformed format schemas and bypasses throwing #121

Description

@MicroMilo

Summary

formatAssertion: false removes the entire format keyword handler, not just instance assertions. Consequently {format: 0} stops producing a schema error, bypasses throwOnInvalidSchema, and is mislabeled as an unknown keyword.

Validation source commit: 1cc2a3045f615ef67104f02449c6fd58afebeb6a.

Code path

  • src/compileSchema.ts:74-84: CompileOptions defines formatAssertion as controlling format assertions and separately defines input-schema throwing.
  • src/keywords/format.ts:14-25: Runtime schema parser requires the format keyword value to be a string.
  • src/validateSchema.test.ts:105-108: Repository test requires a malformed format keyword to produce a schema error.
  • src/compileSchema.ts:160-162: Implementation removes the complete format keyword handler when assertions are disabled.
  • Repository-local validation artifact: Differential replay and assertions.

Steps to reproduce

This report is based on a source-control-flow validation against the commit above.

  1. Check out the source commit listed in this report.
  2. Inspect the code path and contract anchors listed above.
  3. Exercise the described boundary/state path: formatAssertion:false hides malformed format schemas and bypasses throwing.
  4. Compare the observed behavior with the expected contract below.

Validation note: Control compilation of {format: 0} with throwOnInvalidSchema throws. Adding only formatAssertion: false unexpectedly yields no throw, no schemaErrors, and unknown-keyword-warning.

Expected behavior

The implementation should preserve the repository contract described by the documentation, public type, parser, serializer, or sibling implementation anchors above.

Actual behavior

formatAssertion: false removes the entire format keyword handler, not just instance assertions. Consequently {format: 0} stops producing a schema error, bypasses throwOnInvalidSchema, and is mislabeled as an unknown keyword.

Existing coverage

I did not find an existing issue or PR title that appears to cover this exact root cause in the pre-submission check.

Suggested fix

Keep format schema validation active when format instance assertions are disabled.

Suggested tests

  • Add a regression test for: formatAssertion:false hides malformed format schemas and bypasses throwing.
  • Include the boundary value or state transition described above so the old behavior fails before the fix.

Submitted with Codex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions