Skip to content

Commit

Permalink
fix(jsonschema): skips populating default if property not in instance
Browse files Browse the repository at this point in the history
This commit fixes an issue in the set_default wrapper of the validator
where a property that may not be in the manifest is being set if it has
a default associated with it. This leads to inconsistencies when
attributes like additionalProperties are used.
  • Loading branch information
pallabpain committed Jan 23, 2024
1 parent 5870508 commit ba7eccf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions riocli/jsonschema/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def set_defaults(validator, properties, instance, schema):
for p, sub_schema in properties.items():
if "default" not in sub_schema:
continue

# Skip if property is not in instance
if p not in instance:
continue

if isinstance(instance, dict):
instance.setdefault(p, sub_schema["default"])
if isinstance(instance, list):
Expand Down

0 comments on commit ba7eccf

Please sign in to comment.