webhooks: Pass helpful strings to UnsupportedWebhookEventTypeError.

This helps understand _what_ event type was not supported.
This commit is contained in:
Alex Vandiver
2023-10-05 22:20:38 +00:00
committed by Tim Abbott
parent 69326930ff
commit 1e09de1da6
3 changed files with 3 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ def handle_scanning_completed_event(
scan_results = ""
scan_overview = payload["event_data"]["resources"][0]["scan_overview"]
if "application/vnd.security.vulnerability.report; version=1.1" not in scan_overview:
raise UnsupportedWebhookEventTypeError("Unsupported harbor scanning webhook payload")
raise UnsupportedWebhookEventTypeError(str(list(scan_overview.keys())))
scan_summaries = scan_overview["application/vnd.security.vulnerability.report; version=1.1"][
"summary"
]["summary"]

View File

@@ -146,7 +146,7 @@ def get_topic(user_specified_topic: Optional[str], event: str, payload: WildValu
issue_id = payload["data"]["id"].tame(check_string)
return issue_id
raise UnsupportedWebhookEventTypeError("unknown event type")
raise UnsupportedWebhookEventTypeError(event)
def get_event_type(payload: WildValue) -> Optional[str]:

View File

@@ -228,7 +228,7 @@ def handle_issue_payload(
body = ISSUE_IGNORED_MESSAGE_TEMPLATE.format(**context)
else:
raise UnsupportedWebhookEventTypeError("unknown-issue-action type")
raise UnsupportedWebhookEventTypeError(f"{action} action")
return (topic, body)