Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
gocd: Strengthen types using WildValue.
Hari Prashant Bhimarajuac1a38db7588
diff --git a/zerver/webhooks/gocd/view.py b/zerver/webhooks/gocd/view.pyindex b817182661b..a0514754ab6 100644--- a/zerver/webhooks/gocd/view.py+++ b/zerver/webhooks/gocd/view.py@@ -1,13 +1,13 @@# Webhooks for external integrations.import jsonimport os-from typing import Any, Dictfrom django.http import HttpRequest, HttpResponsefrom zerver.decorator import webhook_viewfrom zerver.lib.request import REQ, has_request_variablesfrom zerver.lib.response import json_success+from zerver.lib.validator import WildValue, check_string, to_wild_valuefrom zerver.lib.webhooks.common import check_send_webhook_messagefrom zerver.models import UserProfile@@ -23,11 +23,11 @@ Comment: {}"""def api_gocd_webhook(request: HttpRequest,user_profile: UserProfile,- payload: Dict[str, Any] = REQ(argument_type="body"),+ payload: WildValue = REQ(argument_type="body", converter=to_wild_value),) -> HttpResponse:modifications = payload["build_cause"]["material_revisions"][0]["modifications"][0]- result = payload["stages"][0]["result"]+ result = payload["stages"][0]["result"].tame(check_string)material = payload["build_cause"]["material_revisions"][0]["material"]if result == "Passed":@@ -42,13 +42,13 @@ def api_gocd_webhook(build_link = contents["build_details"]["_links"]["pipeline"]["href"]body = MESSAGE_TEMPLATE.format(- modifications["user_name"],+ modifications["user_name"].tame(check_string),result,emoji,build_link,- modifications["comment"],+ modifications["comment"].tame(check_string),)- branch = material["description"].split(",")+ branch = material["description"].tame(check_string).split(",")topic = branch[0].split(" ")[1]check_send_webhook_message(request, user_profile, topic, body)