diff --git a/src/jbi/router.py b/src/jbi/router.py index e284a3e6..2c7563fd 100644 --- a/src/jbi/router.py +++ b/src/jbi/router.py @@ -40,6 +40,7 @@ def extract_current_action( # pylint: disable=inconsistent-return-statements def execute_action(request: BugzillaWebhookRequest, action_map, settings): """Execute action""" try: + jbi_logger.info("request: %s", request.json()) if not request.bug: raise IgnoreInvalidRequestError("no bug data received") @@ -59,13 +60,12 @@ def execute_action(request: BugzillaWebhookRequest, action_map, settings): callable_action = action_module.init( # type: ignore **current_action["parameters"] ) - jbi_logger.info("request: %s", request.json()) content = callable_action(payload=request) jbi_logger.info("request: %s, content: %s", request.json(), content) return JSONResponse(content=content, status_code=200) except IgnoreInvalidRequestError as exception: invalid_logger.debug("ignore-invalid-request: %s", exception) - return JSONResponse(content={"error": str(exception)}, status_code=202) + return JSONResponse(content={"error": str(exception)}, status_code=200) @api_router.post("/bugzilla_webhook") diff --git a/tests/unit/jbi/test_router.py b/tests/unit/jbi/test_router.py index 9911a540..63eba81c 100644 --- a/tests/unit/jbi/test_router.py +++ b/tests/unit/jbi/test_router.py @@ -24,10 +24,10 @@ def test_request_is_ignored_because_private( "/bugzilla_webhook", data=invalid_webhook_request_example.json() ) assert response - assert response.status_code == 202 + assert response.status_code == 200 assert response.json()["error"] == "private bugs are not valid" - invalid_request_logs = caplog.records[0] + invalid_request_logs = caplog.records[1] assert invalid_request_logs.name == "ignored-requests" assert invalid_request_logs.msg == "ignore-invalid-request: %s" @@ -49,10 +49,10 @@ def test_request_is_ignored_because_no_bug( "/bugzilla_webhook", data=invalid_webhook_request_example.json() ) assert response - assert response.status_code == 202 + assert response.status_code == 200 assert response.json()["error"] == "no bug data received" - invalid_request_logs = caplog.records[0] + invalid_request_logs = caplog.records[1] assert invalid_request_logs.name == "ignored-requests" assert invalid_request_logs.msg == "ignore-invalid-request: %s" @@ -78,13 +78,13 @@ def test_request_is_ignored_because_no_action( "/bugzilla_webhook", data=invalid_webhook_request_example.json() ) assert response - assert response.status_code == 202 + assert response.status_code == 200 assert ( response.json()["error"] == "whiteboard tag not found in configured actions" ) - invalid_request_logs = caplog.records[0] + invalid_request_logs = caplog.records[1] assert invalid_request_logs.name == "ignored-requests" assert invalid_request_logs.msg == "ignore-invalid-request: %s"