Skip to content

Not automatically resolving remote references (in 4.18) breaks backwards compatibility #1089

@joooeey

Description

@joooeey

Even the most basic use case of fetching a HTTPS ref fails. I.e. with the simple schema:

{"$ref": "https://geojson.org/schema/Point.json"}

I've tried a few others.

Python 3.11.2 (main, Mar 27 2023, 23:42:44) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jsonschema
>>> jsonschema.validate(
...     instance={"type": "Point", "coordinates": [0, 1]},
...     schema={"$ref": "https://geojson.org/schema/Point.json"},
... )
Traceback (most recent call last):
  File "/home/lukas/anaconda3/envs/json/lib/python3.11/site-packages/jsonschema/validators.py", line 406, in _validate_reference
    resolved = self._resolver.lookup(ref)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lukas/anaconda3/envs/json/lib/python3.11/site-packages/referencing/_core.py", line 582, in lookup
    raise exceptions.Unresolvable(ref=ref) from None
referencing.exceptions.Unresolvable: https://geojson.org/schema/Point.json

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lukas/anaconda3/envs/json/lib/python3.11/site-packages/jsonschema/validators.py", line 1263, in validate
    error = exceptions.best_match(validator.iter_errors(instance))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lukas/anaconda3/envs/json/lib/python3.11/site-packages/jsonschema/exceptions.py", line 424, in best_match
    best = next(errors, None)
           ^^^^^^^^^^^^^^^^^^
  File "/home/lukas/anaconda3/envs/json/lib/python3.11/site-packages/jsonschema/validators.py", line 331, in iter_errors
    for error in errors:
  File "/home/lukas/anaconda3/envs/json/lib/python3.11/site-packages/jsonschema/_validators.py", line 284, in ref
    yield from validator._validate_reference(ref=ref, instance=instance)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lukas/anaconda3/envs/json/lib/python3.11/site-packages/jsonschema/validators.py", line 408, in _validate_reference
    raise exceptions._WrappedReferencingError(err)
jsonschema.exceptions._WrappedReferencingError: <exception str() failed>
>>> 

In 4.17.3, the jsonschema.validate(...) call prints nothing (returns None) as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething doesn't work the way it should.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions