Skip to content

Commit ec0e91c

Browse files
trevor-eclaude
andcommitted
fix(seer): Return the resolver response on continue, not a blanket 400
Continue ignored resolve_seer_run_state_id's error response and flattened every unresolved id to 400 Invalid run_id, inconsistent with GET on the same id. Return the resolver's response instead, so a not-found run is a 404 and a malformed id stays a 400. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d8f5847 commit ec0e91c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/sentry/seer/endpoints/organization_seer_agent_chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def post(
264264
if run_id:
265265
seer_run_id_or_response = resolve_seer_run_state_id(run_id, organization)
266266
if isinstance(seer_run_id_or_response, Response):
267-
return Response({"detail": "Invalid run_id"}, status=400)
267+
return seer_run_id_or_response
268268
seer_run_state_id = seer_run_id_or_response
269269
# Continue existing conversation
270270
result_run_id = client.continue_run(

tests/sentry/seer/endpoints/test_organization_seer_agent_chat.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,27 @@ def test_post_continue_with_uuid_resolves(self, mock_client_class: MagicMock) ->
254254
assert mock_client.continue_run.call_args.kwargs["run_id"] == 555
255255

256256
@patch("sentry.seer.endpoints.organization_seer_agent_chat.SeerAgentClient")
257-
def test_post_continue_with_unknown_uuid_returns_400(
257+
def test_post_continue_with_unknown_uuid_returns_404(
258258
self, mock_client_class: MagicMock
259259
) -> None:
260260
mock_client = MagicMock()
261261
mock_client_class.return_value = mock_client
262262

263263
response = self.client.post(f"{self.url}{uuid.uuid4()}/", {"query": "More"}, format="json")
264264

265+
assert response.status_code == 404
266+
assert response.data == {"session": None}
267+
mock_client.continue_run.assert_not_called()
268+
269+
@patch("sentry.seer.endpoints.organization_seer_agent_chat.SeerAgentClient")
270+
def test_post_continue_with_garbage_run_id_returns_400(
271+
self, mock_client_class: MagicMock
272+
) -> None:
273+
mock_client = MagicMock()
274+
mock_client_class.return_value = mock_client
275+
276+
response = self.client.post(f"{self.url}not-a-real-id/", {"query": "More"}, format="json")
277+
265278
assert response.status_code == 400
266279
mock_client.continue_run.assert_not_called()
267280

0 commit comments

Comments
 (0)