Unable to reference local "urn:" URI when used in indirection (draft-07 schema)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by reproducing the draft-07 example with check_jsonschema --schemafile values.schema.json values.yaml, then inspect the schema-resolution path around check_jsonschema/checker.py:85 and the referenced jsonschema resolver frames. Done means the local urn: indirection is handled correctly for draft-07 while preserving the existing 2019-09 behavior, with regression coverage for the supplied schemas.
Written by the indexing model from the issue text.
Description
check-jsonschema seems to fail to resolve a $ref in draft-07 schema when used as indirection.
I do not rule out an error in the schema I am using, but I have personally been unable to verify any non-compliance to the spec: https://json-schema.org/draft-07
Notes:
- The schema will work with
check-jsonschemaifdraft-07is changed to2019-09(and"definitions"changed to"$defs"). - The schema works fine when used with
helm.
Contrived example:
values.yaml:
someVal: "a string"
values.schema.json:
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "urn:my-project:helm:schemas:v1:my-helm-chart",
"type": "object",
"properties": {
"someVal": {
"$ref": "urn:my-project:helm:schemas:v1:my-helm-chart/unnecessary-indirection"
}
},
"definitions": {
"indirection": {
"$id": "urn:my-project:helm:schemas:v1:my-helm-chart/unnecessary-indirection",
"$ref": "urn:my-project:helm:schemas:v1:my-helm-chart/string-type"
},
"string": {
"$id": "urn:my-project:helm:schemas:v1:my-helm-chart/string-type",
"type": "string"
}
}
}
Results:
> check_jsonschema --schemafile values.schema.json values.yaml
Failure resolving $ref within schema
_WrappedReferencingError: Unresolvable: urn:my-project:helm:schemas:v1:my-helm-chart/unnecessary-indirection
in "/local/workspace/repos/_external/check-jsonschema/venv/lib/python3.12/site-packages/check_jsonschema/checker.py", line 85
>>> result = self._build_result()
caused by
Unresolvable: urn:my-project:helm:schemas:v1:my-helm-chart/unnecessary-indirection
in "/local/workspace/repos/_external/check-jsonschema/venv/lib/python3.12/site-packages/jsonschema/validators.py", line 463
>>> resolved = self._resolver.lookup(ref)
caused by
Unretrievable: 'urn:my-project:helm:schemas:v1:my-helm-chart/unnecessary-indirection'
in "/local/workspace/repos/_external/check-jsonschema/venv/lib/python3.12/site-packages/referencing/_core.py", line 682
>>> retrieved = self._registry.get_or_retrieve(uri)
caused by
FileNotFoundError: [Errno 2] No such file or directory: '/local/workspace/repos/_external/check-jsonschema/urn:my-project:helm:schemas:v1:my-helm-chart/unnecessary-indirection'
in "/local/workspace/repos/_external/check-jsonschema/venv/lib/python3.12/site-packages/referencing/_core.py", line 428
>>> resource = registry._retrieve(uri)
Background
At $workplace, all helm charts gets their values.schema.json generated by a tool that heavily uses $ref properties to split up the file into multiple schemas. The resulting schema works as intended with helm CLI command.
I have started running the schemas against other schema validators than helm to see if there are any differences in the validation results. I do this both for fun and for trying to find possible improvements to our schemas.
- Dominant language
- Python
- Stars
- 341
- Forks
- 71
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-jsonschema/check-jsonschema
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
enhancement
python-jsonschema/check-jsonschema#668 · 9 comments · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
python-jsonschema/check-jsonschema#655 · 1 reaction ·
All issues in python-jsonschema/check-jsonschema
Similar issues
-
area: harness bug status: needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Human-Agent-Society/reef#625 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
learningequality/kolibri#15351 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Name consistency Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
eellak/triplestore#65 · 1 comment ·