From 47a1e0340433ff353b86a7e9e0e24f7d2c5c8a91 Mon Sep 17 00:00:00 2001 From: Giuseppe Steduto Date: Tue, 21 Nov 2023 16:42:34 +0100 Subject: [PATCH] validation: improve warning message for unexpected properties Change validation.utils so that the warning message for additional unexpected properties also includes the path in reana.yaml where the unexpected property was found. Closes #679. --- reana_client/validation/utils.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/reana_client/validation/utils.py b/reana_client/validation/utils.py index 3d9e2ea1..c1c418ef 100644 --- a/reana_client/validation/utils.py +++ b/reana_client/validation/utils.py @@ -58,15 +58,21 @@ def validate_reana_spec( msg_type="warning", indented=True, ) - for warning_key, warning_value in validation_warnings.items(): + for warning_key, warning_values in validation_warnings.items(): if warning_key == "additional_properties": # warning_values is a list of unexpected properties + messages = [ + f"'{value['property']}' (at {value['path']})" + for value in warning_values + ] message = ( f"Unexpected properties found in REANA specification file: " - f"{', '.join(warning_value)}" + f"{', '.join(messages)}." ) else: - message = warning_value + # warning_values is a list of dictionaries with 'message' and 'path' + messages = [f"{value['message']} (at {value['path']})" for value in warning_values] + message = f"{'; '.join(messages)}." display_message( message, msg_type="warning",