|
31 | 31 | from sentry.seer.explorer.client import SeerExplorerClient |
32 | 32 | from sentry.seer.explorer.client_models import SeerRunState |
33 | 33 | from sentry.seer.models import SeerRepoDefinition |
| 34 | +from sentry.seer.models.seer_api_models import SeerPermissionError |
34 | 35 | from sentry.sentry_apps.metrics import SentryAppEventType |
35 | 36 | from sentry.sentry_apps.tasks.sentry_apps import broadcast_webhooks_for_organization |
36 | 37 | from sentry.sentry_apps.utils.webhooks import SeerActionType |
@@ -451,12 +452,7 @@ def trigger_coding_agent_handoff( |
451 | 452 | "failures": [{"error_message": "No repositories configured in project preferences"}], |
452 | 453 | } |
453 | 454 |
|
454 | | - client = SeerExplorerClient( |
455 | | - organization=group.organization, |
456 | | - user=None, |
457 | | - category_key="autofix", |
458 | | - category_value=str(group.id), |
459 | | - ) |
| 455 | + client = get_autofix_explorer_client(group) |
460 | 456 | state = client.get_run(run_id) |
461 | 457 |
|
462 | 458 | repo = _get_relevant_repo(state, repo_definitions, run_id, group) |
@@ -500,4 +496,10 @@ def trigger_coding_agent_handoff( |
500 | 496 |
|
501 | 497 | def trigger_push_changes(group: Group, run_id: int): |
502 | 498 | client = get_autofix_explorer_client(group) |
| 499 | + |
| 500 | + state = client.get_run(run_id) |
| 501 | + group_id = state.metadata.get("group_id") if state.metadata else None |
| 502 | + if group_id != group.id: |
| 503 | + raise SeerPermissionError("Unknown run id for group") |
| 504 | + |
503 | 505 | client.push_changes(run_id, blocking=False) |
0 commit comments