diff --git a/api/tests/unit/webhooks/test_unit_webhooks.py b/api/tests/unit/webhooks/test_unit_webhooks.py index 9ef69bcd2561..9561bee1f561 100644 --- a/api/tests/unit/webhooks/test_unit_webhooks.py +++ b/api/tests/unit/webhooks/test_unit_webhooks.py @@ -434,10 +434,10 @@ def test_send_test_webhook__various_error_status_codes__returns_correct_response mock_post.assert_called_once() response_json = response.json() assert response_json["status"] == external_api_response_status - assert response_json["detail"] == "Webhook returned invalid status" + assert response_json["detail"] == "Webhook returned error status" assert ( response_json["body"] - == "Please check the webhook endpoint to validate it returns a 200 OK." + == f"Webhook returned HTTP {external_api_response_status}." ) diff --git a/api/webhooks/views.py b/api/webhooks/views.py index cfb756537eb2..743860c2fce9 100644 --- a/api/webhooks/views.py +++ b/api/webhooks/views.py @@ -47,11 +47,11 @@ def test(self, request: Request) -> Response: else WebhookType.ENVIRONMENT ) response = send_test_request_to_webhook(webhook_url, secret, webhook_type) - if response.status_code != 200: + if response.status_code >= 400: return Response( { - "detail": "Webhook returned invalid status", - "body": "Please check the webhook endpoint to validate it returns a 200 OK.", + "detail": "Webhook returned error status", + "body": f"Webhook returned HTTP {response.status_code}.", "status": response.status_code, }, status=status.HTTP_400_BAD_REQUEST,