Skip to content

Commit ed7697f

Browse files
committed
validator: Handle missing $ref's gracefully
From time to time $ref schemas may be missing due to each schema getting applied at different times or a change makes the schema invalid (and testing was ignored). Instead of this resulting in a backtrace splats return a false schema so only validation fails if used. Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
1 parent 0d2c239 commit ed7697f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dtschema/validator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,11 @@ def __init__(self, schema_files, id_filter=""):
423423
self.schemas['version'] = dtschema.__version__
424424

425425
def retrieve(self, uri):
426-
return DRAFT201909.create_resource(self.schemas[uri])
426+
try:
427+
schema = self.schemas[uri]
428+
except KeyError:
429+
schema = False
430+
return DRAFT201909.create_resource(schema)
427431

428432
def annotate_error(self, id, error):
429433
error.schema_file = id

0 commit comments

Comments
 (0)