Repository navigation
Unable to reference local "urn:" URI when used in indirection (draft-07 schema) #549
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.
Activity
MbappeWU commentedon Oct 11, 2026
This looks like expected draft-07 behavior rather than a check-jsonschema bug: section 8.3 ("Schema References With
$ref") says "All other properties in a "$ref" object MUST be ignored."The
$idbeside$refindefinitions.indirectionis therefore ignored and never registered, sourn:my-project:helm:schemas:v1:my-helm-chart/unnecessary-indirectioncannot be resolved.On draft-07, keep that
$idand move the$refunderallOf. Full schema:{ "$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", "allOf": [ { "$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" } } }With this schema,
check-jsonschema --schemafile values.schema.json values.yamlpasses forsomeVal: "a string"and reports1 is not of type 'string'forsomeVal: 1.Switching to 2019-09+, where
$refmay have siblings, also works with$defs, as you already observed.Verified both with check-jsonschema 0.38.2 locally.