Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
teamcity: Ignore unsupported build results instead of crashing.
Anders Kaseorg5f4f2b8726f8
diff --git a/zerver/webhooks/teamcity/tests.py b/zerver/webhooks/teamcity/tests.pyindex a8607f4b6f5..f45a4aa52ad 100644--- a/zerver/webhooks/teamcity/tests.py+++ b/zerver/webhooks/teamcity/tests.py@@ -32,6 +32,17 @@ class TeamCityHookTests(WebhookTestCase):expected_message = "Project :: Compile build 5535 - CL 123456 has been fixed! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."self.check_webhook("fixed", self.TOPIC_NAME, expected_message)+ def test_teamcity_unsupported_build_result(self) -> None:+ payload = self.get_body("success").replace(+ '"buildResult": "success"', '"buildResult": "unsupported"'+ )+ result = self.client_post(self.url, payload, content_type="application/json")+ self.assert_json_success(result)+ self.assert_in_response(+ "The 'unsupported' event isn't currently supported by the TeamCity webhook; ignoring",+ result,+ )+def test_teamcity_personal(self) -> None:expected_message = "Your personal build for Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."payload = orjson.dumps(diff --git a/zerver/webhooks/teamcity/view.py b/zerver/webhooks/teamcity/view.pyindex 6cdb2dd1950..cd18652fa83 100644--- a/zerver/webhooks/teamcity/view.py+++ b/zerver/webhooks/teamcity/view.py@@ -9,6 +9,7 @@ from zerver.actions.message_send import (send_rate_limited_pm_notification_to_bot_owner,)from zerver.decorator import webhook_view+from zerver.lib.exceptions import UnsupportedWebhookEventTypeErrorfrom zerver.lib.request import RequestNotesfrom zerver.lib.response import json_successfrom zerver.lib.send_email import FromAddress@@ -91,6 +92,8 @@ def api_teamcity_webhook(status = f"is still broken with status {build_status}! :thumbs_down:"elif build_result == "running":status = "has started."+ else:+ raise UnsupportedWebhookEventTypeError(build_result)template = """{build_name} build {build_id} {status} See [changes]\