From f710a1f2d99fa0816c77270ad9923e6dd759cdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rkan?= <93771679+Bjorkan@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:03:08 +0200 Subject: [PATCH] Change failed trace from using 504 to instead use 422 --- app/routers/contacts.py | 2 +- app/routers/radio.py | 4 ++-- tests/test_radio_router.py | 4 ++-- tests/test_repeater_routes.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/routers/contacts.py b/app/routers/contacts.py index 00d332e..0fe51f0 100644 --- a/app/routers/contacts.py +++ b/app/routers/contacts.py @@ -462,7 +462,7 @@ async def request_trace(public_key: str) -> TraceResponse: ) if event is None: - raise HTTPException(status_code=504, detail="No trace response heard") + raise HTTPException(status_code=422, detail="No trace response heard") trace = event.payload path = trace.get("path", []) diff --git a/app/routers/radio.py b/app/routers/radio.py index aad08f7..71fe7ee 100644 --- a/app/routers/radio.py +++ b/app/routers/radio.py @@ -561,7 +561,7 @@ async def trace_path(request: RadioTraceRequest) -> RadioTraceResponse: try: event = await asyncio.wait_for(response_task, timeout=timeout_seconds) except TimeoutError as exc: - raise HTTPException(status_code=504, detail="No trace response heard") from exc + raise HTTPException(status_code=422, detail="No trace response heard") from exc finally: if not response_task.done(): response_task.cancel() @@ -569,7 +569,7 @@ async def trace_path(request: RadioTraceRequest) -> RadioTraceResponse: await response_task if event is None: - raise HTTPException(status_code=504, detail="No trace response heard") + raise HTTPException(status_code=422, detail="No trace response heard") payload = event.payload if isinstance(event.payload, dict) else {} path_len = payload.get("path_len") diff --git a/tests/test_radio_router.py b/tests/test_radio_router.py index 55c981f..7fa20b3 100644 --- a/tests/test_radio_router.py +++ b/tests/test_radio_router.py @@ -699,7 +699,7 @@ class TestTracePath: assert "not a repeater" in exc.value.detail @pytest.mark.asyncio - async def test_returns_504_when_no_trace_response_is_heard(self): + async def test_returns_422_when_no_trace_response_is_heard(self): mc = _mock_meshcore_with_info() repeater = Contact( public_key="44" * 32, @@ -741,7 +741,7 @@ class TestTracePath: ) ) - assert exc.value.status_code == 504 + assert exc.value.status_code == 422 assert "No trace response heard" in exc.value.detail @pytest.mark.asyncio diff --git a/tests/test_repeater_routes.py b/tests/test_repeater_routes.py index d482b89..3a47afd 100644 --- a/tests/test_repeater_routes.py +++ b/tests/test_repeater_routes.py @@ -510,7 +510,7 @@ class TestTraceRoute: ) @pytest.mark.asyncio - async def test_wait_timeout_returns_504(self, test_db): + async def test_wait_timeout_returns_422(self, test_db): mc = _mock_mc() await _insert_contact(KEY_A, name="Client", contact_type=1) mc.commands.send_trace = AsyncMock(return_value=_radio_result(EventType.OK)) @@ -524,7 +524,7 @@ class TestTraceRoute: with pytest.raises(HTTPException) as exc: await request_trace(KEY_A) - assert exc.value.status_code == 504 + assert exc.value.status_code == 422 mc.commands.send_trace.assert_awaited_once_with( path=KEY_A[:8], tag=1234,