Forward compatibility with must-understand keywords #119
Replies: 7 comments 40 replies
-
I'm confused. This use case is fully supported by vocabularies and dialects. This is exactly what they are for. Are you wanting another method on top of that? |
Beta Was this translation helpful? Give feedback.
-
Replying to your comments at #69 (comment)
How is this associated with an RFC?
Doesn't this support the idea of writing schemas without defining a dialect ( I think your whole proposition rests on the idea that once we announce a "stable" version or publish a "fully fledged RFC", people will recognise and use that over older versions, and use implementations which implement it over existing other implementations. I think this is a false presumption, and the horse has already bolted/ship has already sailed. This is one of the drivers for dialects and vocabularies: drive forward adoption with the promise of standardised, reliable, interoperable, predicatable behaviour based on requirements. |
Beta Was this translation helpful? Give feedback.
-
This section I wrote recently for UJS is relevant to this discussion. It's guidelines for using custom keywords and pitfalls to look out for. https://json-schema.org/understanding-json-schema/reference/schema.html#vocabularies As for submitting to IETF. I strongly believe that the only keyword we should be defining for IETF is |
Beta Was this translation helpful? Give feedback.
-
I don't think what you are proposing is actually forward compatibility. Here's a definition of forward compatibility from Wikipedia.
As soon as you introduce a new must-understand keyword, you've broken forward compatibility. The old implementation would throw an error given a schema from the new standard, not gracefully degrade by ignoring keywords it doesn't understand. Forward compatibility doesn't mean the older implementation can never produce different results than the newer implementation, it just means that it must accept the newer schema and do the best it can. As far as the specification is concerned, I think JSON Schema satisfies forward compatibility by ignoring unknown keywords. Beyond that, we would need to make a commitment to not making changes to keywords that aren't forward compatible. From the UJS Vocabularies examples, we see that ignoring keywords you don't understand is more "graceful" is some cases ( We would have to come up with criteria for what level of degradation we consider "graceful" when considering new keywords. I think that false positives are graceful while false negatives are not. In the UJS examples, we talk about the schemas being used on the front-end and on the back-end. If the validator on the front-end skips an assertion, it's not the end of the world because the error will be caught on the back-end. However, if you enter valid data and get a false negative on the front-end, that's a serious problem. It would block the user from proceeding. It wouldn't be unreasonable for JSON Schema to make a commitment to forward and backward compatibility and drop version identifiers going forward like HTML. There would be some consequences that we would have to think through carefully and be ok with a bit of a change of direction. I'm not a fan of the proposal, but I do think it's worth discussing whether or not we want to commit to forward and backward compatibility going forward. |
Beta Was this translation helpful? Give feedback.
-
After some discussion, I think we are generally on the same page. The following are things that we might want to support in JSON Schema. The first two are not currently supported, while the second two are supported. The first step is to get agreement on which properties we want JSON Schema to have. Then we can entertain proposals to make it happen.
|
Beta Was this translation helpful? Give feedback.
-
Far off consideration, but what do ya'll think about versioning here? If we released what we call a "stable" or forwards compatible specification, should we use semantic versioning for releases? If we want to send those signals, semver is a good way to make promises. @jdesrosiers this seems to be opposed to your notion of a living standard. Have you been convinced otherwise or am I missing something? |
Beta Was this translation helpful? Give feedback.
-
I don't think we're at a place where we can promise no breaking changes, either forward or backwards. But we can make some commitments, which we can put in the spec so they're solid (some of these are new proposals, others are not):
I think with this foundation, any implementation should be able to bootstrap any schema created now or using a future specification version, and either be able to process it or be able to generate a sane error that it can't process it (and why). e.g. consider an implementation that only understands up to draft2020-12, and we've released 2022-06 which totally changes how the '$vocabulary' keyword works. It is given this schema to process:
Because we've guaranteed the consistency of "$id" and "$schema", it knows how to get started: first it needs to determine the dialect that this schema is written in. It doesn't know this metaschema, but it is capable of loading schemas from the network, so it goes to fetch http://acmecorp.com/furble/metaschema, which is:
Here's another $schema URI that it doesn't know, so it has to load this one too. It is:
Now we've got a $schema keyword that is the same as the document we're already trying to process -- so are unable to process further, and must return an error. [Humans reading this will recognize that this means we are looking at a specification metaschema, but an implementation doesn't need to make this distinction -- it can just recognize that a schema has been defined in terms of itself, and therefore it can go no further.] This is all possible because we've guaranteed the consistency and integrity of the "$id" and "$schema" keywords. If in a future version we'd (for example) renamed "$id" to "$identifier" or "$schema" to "$schema-uri", an older implementation might think there is no identifier or schema declared in the schema at all, and proceed with assuming sensible defaults, which might result in interesting and unpredictable errors as it tried to apply older logic to newer keywords. |
Beta Was this translation helpful? Give feedback.
-
When submitting JSON Schema as an Internet media type (e.g.
application/schema+json
), one of the potential problems in JSON Schema is: how does it support forward compatibility?This would be easy to implement if there were some standard way to distinguish between must-understand keywords and may-understand keywords. This way, a validator could understand when there's a keyword that should be performing validation, but that is not implemented.
This example uses keywords that contain a
.
to denote keywords that are may-implement, and other keywords are mandatory, must-understand:Or using TitleCamelCase, which may be friendlier when encoding schemas as ECMAScript objects (afaik, we don't have any keywords that begin with a capital letter):
The other way to do this would be to indicate the must-understand keywords, for example, a
!
suffix:Beta Was this translation helpful? Give feedback.
All reactions