Skip to content

resolve ambiguity regarding annotation inclusion in failed validation results #939

Closed
@karenetheridge

Description

@karenetheridge

The spec says (https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.7.7.1.2):

Schema objects that produce a false assertion result MUST NOT produce any annotation results, whether from their own keywords or from keywords in subschemas.

However, this is contradicted by other parts of the spec
(https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.10.4.4):

This includes sub-schema validation results that would otherwise be removed (e.g. annotations for failed validations, successful validations inside a not keyword, etc.).

So, it would appear there are cases where annotations should be included in a result even if the
overall validation result is false. (e.g. if one branch of an allOf was successful and produced annotations, but another branch failed, this means that the subschema at allOf fails, so it should discard all annotations collected below that point and simply return its valid: "failed" and errors: [..] results back up to the next-higher node. But in the end, annotations are still not returned in the final result.

This (section 10.4.4) also implies that an implementation cannot simply discard
all collected annotations at a schema position where validation fails: it must continue to collect
them in case the "verbose" output method is requested.


Now, another usecase:

I have a desire to include annotations in failed validation result, so as to provide more
information as to the nature of the failure (or perhaps offer extra guidance as to how to make
validation succeed).·

(cross-ref: https://github.com/karenetheridge/JSON-Schema-Draft201909/issues/22)

I can achieve this with a simple annotation-only keyword (e.g. "description", or a new one that acts
like "description" by returning data at the position it is evaluated), except for this item of the
spec that says that annotations are discarded on failed results.

Is there a way through this? At the very least, it seems as if there is some contradictory language
in the spec that could be clarified.

Metadata

Metadata

Labels

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions