mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
webhooks: Pass helpful strings to UnsupportedWebhookEventTypeError.
This helps understand _what_ event type was not supported.
This commit is contained in:
committed by
Tim Abbott
parent
69326930ff
commit
1e09de1da6
@@ -65,7 +65,7 @@ def handle_scanning_completed_event(
|
|||||||
scan_results = ""
|
scan_results = ""
|
||||||
scan_overview = payload["event_data"]["resources"][0]["scan_overview"]
|
scan_overview = payload["event_data"]["resources"][0]["scan_overview"]
|
||||||
if "application/vnd.security.vulnerability.report; version=1.1" not in 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"][
|
scan_summaries = scan_overview["application/vnd.security.vulnerability.report; version=1.1"][
|
||||||
"summary"
|
"summary"
|
||||||
]["summary"]
|
]["summary"]
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ def get_topic(user_specified_topic: Optional[str], event: str, payload: WildValu
|
|||||||
issue_id = payload["data"]["id"].tame(check_string)
|
issue_id = payload["data"]["id"].tame(check_string)
|
||||||
return issue_id
|
return issue_id
|
||||||
|
|
||||||
raise UnsupportedWebhookEventTypeError("unknown event type")
|
raise UnsupportedWebhookEventTypeError(event)
|
||||||
|
|
||||||
|
|
||||||
def get_event_type(payload: WildValue) -> Optional[str]:
|
def get_event_type(payload: WildValue) -> Optional[str]:
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ def handle_issue_payload(
|
|||||||
body = ISSUE_IGNORED_MESSAGE_TEMPLATE.format(**context)
|
body = ISSUE_IGNORED_MESSAGE_TEMPLATE.format(**context)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise UnsupportedWebhookEventTypeError("unknown-issue-action type")
|
raise UnsupportedWebhookEventTypeError(f"{action} action")
|
||||||
|
|
||||||
return (topic, body)
|
return (topic, body)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user