Skip to content

Commit

Permalink
validation: improve warning message for unexpected properties
Browse files Browse the repository at this point in the history
Change the warning message generated when unexpected properties are
found in the REANA specification during the validation phase to include
the path to the invalidating properties.

Closes reanahub#679.
  • Loading branch information
giuseppe-steduto committed Nov 22, 2023
1 parent 691a378 commit a6a4974
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions reana_client/validation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,24 @@ 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 a6a4974

Please sign in to comment.