From 424bacc71ef64dbd9e092450d5fbc13fbe70c8ab Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Tue, 21 Nov 2023 21:35:26 +0200 Subject: [PATCH] fix(schema): Warn if missing dependency (#4616) Previously users that didn't have the python jsonschema dependency installed would "succeed" to validate a user configuration. Fix it. --- cloudinit/config/schema.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py index 55915af9ecb..f62f1dd2f55 100644 --- a/cloudinit/config/schema.py +++ b/cloudinit/config/schema.py @@ -628,6 +628,7 @@ def validate_cloudconfig_schema( "see the schema errors." ) LOG.warning(details) + return True class _Annotator: @@ -957,9 +958,14 @@ def validate_cloudconfig_file( ) return False try: - validate_cloudconfig_schema( + if not validate_cloudconfig_schema( cloudconfig, schema, strict=True, log_deprecations=False - ) + ): + print( + f"Skipping {schema_type} schema validation." + " Jsonschema dependency missing." + ) + return False except SchemaValidationError as e: if e.has_errors(): errors += e.schema_errors