Skip to content

Commit 2b4ccff

Browse files
committed
Add more context to config generator validation errors
1 parent 1b7ca82 commit 2b4ccff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/config_generator/config_generator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,9 @@ def validate_schema(self, config, schema_url):
617617
path += "[%d]" % p
618618
else:
619619
path += ".%s" % p
620+
context = config
621+
for p in list(error.absolute_path)[:-1]:
622+
context = context[p]
620623

621624
# get concerned subconfig
622625
instance = error.instance
@@ -646,9 +649,10 @@ def validate_schema(self, config, schema_url):
646649
self.logger.warning("Location: %s" % path)
647650
self.logger.warning(
648651
"Value: %s" %
649-
json.dumps(
650-
instance, sort_keys=False, indent=2, ensure_ascii=False
651-
)
652+
json.dumps(instance, sort_keys=False, indent=2, ensure_ascii=False)
653+
)
654+
self.logger.warning(
655+
"Context: %s" % json.dumps(context, sort_keys=False, indent=2, ensure_ascii=False)
652656
)
653657

654658
return valid

0 commit comments

Comments
 (0)