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

Relative $refs crash when $id is a URN or other custom scheme #544

Closed
dstokesf5 opened this issue Mar 21, 2019 · 0 comments
Closed

Relative $refs crash when $id is a URN or other custom scheme #544

dstokesf5 opened this issue Mar 21, 2019 · 0 comments
Labels
Bug Something doesn't work the way it should. Needs Test Upstream Issues that need to have a test added to https://github.com/json-schema-org/JSON-Schema-Test-Suite

Comments

@dstokesf5
Copy link

Using a URN for the $id property in a schema is causing many URL related errors:

Traceback (most recent call last):
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 739, in resolve_from_url
    document = self.store[url]
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/_utils.py", line 23, in __getitem__
    return self.store[self.normalize(uri)]
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 742, in resolve_from_url
    document = self.resolve_remote(url)
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 828, in resolve_remote
    with urlopen(uri) as url:
  File "/usr/lib64/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.7/urllib/request.py", line 510, in open
    req = Request(fullurl, data)
  File "/usr/lib64/python3.7/urllib/request.py", line 328, in __init__
    self.full_url = url
  File "/usr/lib64/python3.7/urllib/request.py", line 354, in full_url
    self._parse()
  File "/usr/lib64/python3.7/urllib/request.py", line 383, in _parse
    raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/bin/jsonschema", line 10, in <module>
    sys.exit(main())
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/cli.py", line 67, in main
    sys.exit(run(arguments=parse_args(args=args)))
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/cli.py", line 78, in run
    for error in validator.iter_errors(instance):
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 323, in iter_errors
    for error in errors:
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/_validators.py", line 303, in allOf
    for error in validator.descend(instance, subschema, schema_path=index):
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 339, in descend
    for error in self.iter_errors(instance, schema):
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 323, in iter_errors
    for error in errors:
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/_validators.py", line 247, in ref
    scope, resolved = validator.resolver.resolve(ref)
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 734, in resolve
    return url, self._remote_cache(url)
  File "/pdhome/dstokes/dev/f5-appsvcs/venv/lib/python3.7/site-packages/jsonschema/validators.py", line 744, in resolve_from_url
    raise exceptions.RefResolutionError(exc)
jsonschema.exceptions.RefResolutionError: unknown url type: ''

This is possibly a duplicate of #313, but I cannot reproduce this without a URN $id.

Schema:

{
    "$id": "urn:uuid:85626792-9ee7-46bb-8fc8-4ba708cfdc1d",
    "allOf": [
        { "$ref": "#/definitions/schema" }
    ],
    "definitions": {
        "schema": {}
    }
}
@Julian Julian added the Bug Something doesn't work the way it should. label Mar 26, 2019
@Julian Julian added the Needs Test Upstream Issues that need to have a test added to https://github.com/json-schema-org/JSON-Schema-Test-Suite label Sep 4, 2019
OrangeTux pushed a commit to mobilityhouse/ocpp that referenced this issue Oct 28, 2019
jsonschemas has a bug with parsing $refs if the schema's $id
is a URN[1]. It basically fails to load the schema.

We don't need the $id. Therefore al $id's have been removed.

[1]: python-jsonschema/jsonschema#544
OrangeTux pushed a commit to mobilityhouse/ocpp that referenced this issue Oct 28, 2019
jsonschemas has a bug with parsing $refs if the schema's $id
is a URN[1]. It basically fails to load the schema.

We don't need the $id. Therefore al $id's have been removed.

[1]: python-jsonschema/jsonschema#544
OrangeTux pushed a commit to mobilityhouse/ocpp that referenced this issue Oct 29, 2019
jsonschemas has a bug with parsing $refs if the schema's $id
is a URN[1]. It basically fails to load the schema.

We don't need the $id. Therefore al $id's have been removed.

[1]: python-jsonschema/jsonschema#544
OrangeTux pushed a commit to mobilityhouse/ocpp that referenced this issue Oct 29, 2019
jsonschemas has a bug with parsing $refs if the schema's $id
is a URN[1]. It basically fails to load the schema.

We don't need the $id. Therefore al $id's have been removed.

[1]: python-jsonschema/jsonschema#544
OrangeTux pushed a commit to mobilityhouse/ocpp that referenced this issue Oct 29, 2019
jsonschemas has a bug with parsing $refs if the schema's $id
is a URN[1]. It basically fails to load the schema.

We don't need the $id. Therefore al $id's have been removed.

[1]: python-jsonschema/jsonschema#544
OrangeTux pushed a commit to mobilityhouse/ocpp that referenced this issue Oct 29, 2019
jsonschemas has a bug with parsing $refs if the schema's $id
is a URN[1]. It basically fails to load the schema.

We don't need the $id. Therefore al $id's have been removed.

[1]: python-jsonschema/jsonschema#544
Julian added a commit that referenced this issue Apr 29, 2022
060caae0d Merge pull request #467 from gene-hightower/strict-rfc-grammar
995932c74 Additional RFC-5321 Mailbox tests
637f0ac3e Merge pull request #542 from jdesrosiers/dyanmicref-no-bookending
87944e52e Merge pull request #543 from jdesrosiers/update-vocabulary-for-draft-next
07b90e3b5 Merge pull request #544 from frawa/list-typed-json
365349adc list typed-json in new Scala section
9d1efc27e Update vocabulary tests for draft-next
89f59caad Update dynamicRef tests for bookenending removal

git-subtree-dir: json
git-subtree-split: 060caae0dd58e34af0449baec1103606a0ef4977
@Julian Julian changed the title Relative $refs crash when $id is a URN Relative $refs crash when $id is a URN or other custom scheme May 20, 2022
@Julian Julian closed this as completed in c9a3667 Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something doesn't work the way it should. Needs Test Upstream Issues that need to have a test added to https://github.com/json-schema-org/JSON-Schema-Test-Suite
Projects
None yet
Development

No branches or pull requests

2 participants