Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make format validate by default #1553

Merged
merged 8 commits into from
Nov 21, 2024
Merged

Conversation

gregsdennis
Copy link
Member

@gregsdennis gregsdennis commented Oct 28, 2024

What kind of change does this PR introduce?

Feature update

Issue & Discussion References

Closes #1520
Depends on json-schema-org/TSC#19

Summary

Makes format an assertion to align with user expectations.

Quick notes:

  • Implementations SHOULD support format with the defined values
  • Implementations MAY support others, but only by explicit config
  • Implementations MUST refuse to process a schema that contains an unsupported format
  • Permissive allowances removed since every format is clearly defined by referencing a specification

Does this PR introduce a breaking change?

Technically a breaking change, but aligns to user expectations. So... ????

@gregsdennis gregsdennis added this to the stable-release milestone Oct 28, 2024
@gregsdennis gregsdennis requested a review from a team October 28, 2024 08:13
@gregsdennis gregsdennis self-assigned this Oct 28, 2024
to any instance types defined in the data model defined in the [core JSON
Schema.](#json-schema)[^1]
The value of this keyword MUST be a string. While this keyword can validate any
type, each distinct value will generally only validate a given set of instance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, it means we let format apply to instances other than strings. If I recall correctly, the JSON Schema test suite very explicitly tests that format only applies to instances, which might be a change that could confuse various people and implementations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, it means we let format apply to instances other than strings.

Yes, format can apply to instances of any type. This isn't a new feature, however, the spec only defines formats that apply to strings.

@jdesrosiers
Copy link
Member

This being a breaking change and a potentially controversial one, I think there should be a TSC vote to formally document that we have consensus before this moves forward. It should also have an ADR to document the decision.

@gregsdennis
Copy link
Member Author

gregsdennis commented Nov 2, 2024

It should also have an ADR to document the decision.

I'll add one.

I think there should be a TSC vote to formally document that we have consensus before this moves forward

I'll create a TSC voting issue summarizing this PR.

@gregsdennis gregsdennis force-pushed the gregsdennis/validated-format branch from 2c9cae4 to e13e156 Compare November 7, 2024 22:40
@gregsdennis gregsdennis requested a review from a team November 13, 2024 00:33
Copy link
Member

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few editorial suggestions, but otherwise, this looks great.

adr/2024-11-2-assertion-format.md Outdated Show resolved Hide resolved
adr/2024-11-2-assertion-format.md Outdated Show resolved Hide resolved
specs/jsonschema-validation.md Outdated Show resolved Hide resolved
specs/jsonschema-validation.md Outdated Show resolved Hide resolved
specs/jsonschema-validation.md Outdated Show resolved Hide resolved
@gregsdennis gregsdennis requested a review from a team November 13, 2024 23:46
@gregsdennis gregsdennis merged commit e3a87d4 into main Nov 21, 2024
6 checks passed
@gregsdennis gregsdennis deleted the gregsdennis/validated-format branch November 21, 2024 20:49
@Relequestual
Copy link
Member

I was initially concerned with some of the wording and the implication for required or optional tests, but it was changed, and I'm now happy. Sharing after the merge as @gregsdennis asked on the TSC vote issue for me to do so, although that was a week ago (sorry). (Partly for my own records

Specifically https://github.com/json-schema-org/json-schema-spec/pull/1553/files#diff-a2feaccf762dd55c4d3dd625aa1b57c48df6f782b8088cd4210fc9b93f8aea17R314-R316

Implementations SHOULD provide assertion behavior for the format values defined
by this document[^2] and MUST refuse to process any schema which contains a
format value it doesn't support.

I was concerned the "SHOULD" was too weak here, but the proceeding "MUST" gives it enough balance. Primarily, this avoids any false positives where a user expects assertion behavior and an implementation goes "shrugs I'll just allow it".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Proposal: Make format validate by default
4 participants