Skip to content

Commit

Permalink
validation: improve warning message for unexpected properties
Browse files Browse the repository at this point in the history
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 reanahub#679.
  • Loading branch information
giuseppe-steduto committed Nov 21, 2023
1 parent bf476f1 commit d948545
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions reana_client/validation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d948545

Please sign in to comment.