Skip to content

add section to specify behavior for failed reference resolution #1439

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

Merged
merged 1 commit into from
Sep 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions jsonschema-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,35 @@ behave correctly under implementations that attempt to use any reference target
as a schema. However, this behavior is implementation-specific and MUST NOT be
relied upon for interoperability.

#### Failure to resolve references

If for any reason a reference cannot be resolved, the evaluation MUST halt and
return an indeterminant result. Specifically, it MUST NOT return a passing or
failing validation result or any annotations. Instead it MUST inform the
consuming application or user of the evaluation failure via other means. It is
RECOMMENDED that implementations utilize native functionality for this purpose,
such as, but not limited to, raising an exception or other error.

In the cases where optimizations are enabled and a schema containing a
non-resolvable reference would be skipped, as in the example below, behavior is
implementation-defined.

```json
{
"anyOf": [
true,
{ "$ref": "https://json-schema.org/does-not-exist" }
]
}
```

Here, an optimized evaluation may recognize that `/anyOf/0` will satisfy the
`anyOf` constraint, regardless of the validation result of `/anyOf/1`, and so
`/anyOf/1` may be skipped altogether.

However, an unoptimized evaluation of this schema (for example one that expects
all annotation results), would result in a resolution failure.

### Associating Instances and Schemas

#### Usage for Hypermedia {#hypermedia}
Expand Down