json-schema-org / JSON-Schema-Test-Suite

A language agnostic test suite for the JSON Schema specifications
MIT License
615 stars 205 forks source link

Unknown `format` handling #717

Closed justin-tay closed 8 months ago

justin-tay commented 8 months ago

The specification seems to imply that when format assertions are enabled an unknown format is considered an error.

From https://json-schema.org/draft/2020-12/json-schema-validation#section-7.2.3

An implementation MUST NOT fail to collect unknown formats as annotations. 
When the Format-Assertion vocabulary is specified, implementations MUST fail upon encountering unknown formats.

Since the tests in optional/format/*.json are intended to be run with format assertions enabled, are the test expectations in optional/format/unknown.json correct?

https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/bf0360f4b7c51b8f968aabe7f3f49e12b120fc85/tests/draft2020-12/optional/format/unknown.json#L3-L44

Julian commented 8 months ago

There's a difference between when the format assertion vocabulary is enabled and when format assertion behavior is enabled. The former is a recent thing, the latter has essentially always existed.

Those tests do not enable the format assertion vocabulary -- they set $schema to the normal draft 2020 dialect ID, which does not require it.

They are however intended to be run (optionally) with format assertion behavior enabled in an implementation using whatever side channel mechanism is available for doing so.

Hope that helps?

justin-tay commented 8 months ago

Ok thanks for the clarification!