Skip to content

Commit 7c99619

Browse files
committed
address pr comments
1 parent 99b9dc4 commit 7c99619

2 files changed

Lines changed: 13 additions & 20 deletions

File tree

src/sentry/seer/autofix/on_completion_hook.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -502,15 +502,6 @@ def _trigger_coding_agent_handoff(
502502
"failures": len(result.get("failures", [])),
503503
},
504504
)
505-
except Group.DoesNotExist:
506-
logger.exception(
507-
"autofix.on_completion_hook.coding_agent_handoff_group_not_found",
508-
extra={
509-
"run_id": run_id,
510-
"organization_id": organization.id,
511-
"group_id": group.id,
512-
},
513-
)
514505
except Exception:
515506
logger.exception(
516507
"autofix.on_completion_hook.coding_agent_handoff_failed",

src/sentry/seer/endpoints/group_ai_autofix.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any
55

66
from drf_spectacular.utils import extend_schema
7-
from rest_framework import serializers
7+
from rest_framework import serializers, status
88
from rest_framework.exceptions import PermissionDenied
99
from rest_framework.request import Request
1010
from rest_framework.response import Response
@@ -225,7 +225,7 @@ def _post_explorer(self, request: Request, group: Group) -> Response:
225225
"""Handle POST for Explorer-based autofix."""
226226
serializer = ExplorerAutofixRequestSerializer(data=request.data)
227227
if not serializer.is_valid():
228-
return Response(serializer.errors, status=400)
228+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
229229

230230
data = serializer.validated_data
231231
step = data.get("step", "root_cause")
@@ -241,12 +241,12 @@ def _post_explorer(self, request: Request, group: Group) -> Response:
241241
{
242242
"detail": "run_id and either integration_id or provider are required for coding_agent_handoff"
243243
},
244-
status=400,
244+
status=status.HTTP_400_BAD_REQUEST,
245245
)
246246
if integration_id and provider:
247247
return Response(
248248
{"detail": "Cannot specify both integration_id and provider"},
249-
status=400,
249+
status=status.HTTP_400_BAD_REQUEST,
250250
)
251251

252252
result = trigger_coding_agent_handoff(
@@ -256,16 +256,18 @@ def _post_explorer(self, request: Request, group: Group) -> Response:
256256
provider=provider,
257257
user_id=request.user.id if request.user else None,
258258
)
259-
return Response(result, status=202)
259+
return Response(result, status=status.HTTP_202_ACCEPTED)
260260

261261
if step == "open_pr":
262262
if not run_id:
263-
return Response({"detail": "run_id is required for open_pr"}, status=400)
263+
return Response(
264+
{"detail": "run_id is required for open_pr"}, status=status.HTTP_400_BAD_REQUEST
265+
)
264266
try:
265267
trigger_push_changes(group, run_id)
266-
except SeerPermissionError as e:
267-
raise PermissionDenied(str(e))
268-
return Response({"run_id": run_id}, status=202)
268+
except SeerPermissionError:
269+
return Response(status=status.HTTP_404_NOT_FOUND)
270+
return Response({"run_id": run_id}, status=status.HTTP_202_ACCEPTED)
269271

270272
# Handle all built-in Seer steps
271273
try:
@@ -278,15 +280,15 @@ def _post_explorer(self, request: Request, group: Group) -> Response:
278280
intelligence_level=data["intelligence_level"],
279281
user_context=data.get("user_context"),
280282
)
281-
return Response({"run_id": run_id}, status=202)
283+
return Response({"run_id": run_id}, status=status.HTTP_202_ACCEPTED)
282284
except SeerPermissionError as e:
283285
raise PermissionDenied(str(e))
284286

285287
def _post_legacy(self, request: Request, group: Group) -> Response:
286288
"""Handle POST for legacy autofix."""
287289
serializer = AutofixRequestSerializer(data=request.data)
288290
if not serializer.is_valid():
289-
return Response(serializer.errors, status=400)
291+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
290292

291293
data = serializer.validated_data
292294

0 commit comments

Comments
 (0)