feat(seer): Add workflows list endpoint for Night Shift runs#113491
Conversation
Add a new organization-scoped endpoint at
/api/0/organizations/{organization_id_or_slug}/seer/workflows/ that
returns paginated SeerNightShiftRun records with nested run issues.
This powers an internal, direct-link-only page for viewing historical
Night Shift workflow runs for an org. The endpoint is gated behind the
organizations:seer-night-shift feature flag and returns 404 when the
flag is off so the existence of the page is not revealed to orgs
without access.
The serializer bulk-fetches SeerNightShiftRunIssue rows in get_attrs to
avoid N+1 queries when listing runs with their nested issues.
Co-Authored-By: Claude <noreply@anthropic.com>
|
🚨 Warning: This pull request contains Frontend and Backend changes! It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently. Have questions? Please ask in the |
Swap the serializer's custom get_attrs bulk fetch for prefetch_related on the endpoint queryset. Same two-query shape, but puts the fetch alongside the filter and drops the get_attrs boilerplate. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dad8b36. Configure here.
Move issue prefetching from the endpoint queryset into the serializer's get_attrs via prefetch_related_objects, so any caller of serialize(runs, user) gets N+1 protection automatically without having to remember to prefetch in the queryset. Matches the pattern used by AuditLogEntrySerializer and DashboardListSerializer. Co-Authored-By: Claude <noreply@anthropic.com>
a9c5b34 to
fba8f91
Compare
Store the Seer agentic triage run id on the SeerNightShiftRun row (under extras["agent_run_id"]) so historical runs can be linked back to their Seer Explorer run without needing to re-invoke the triage. Uses extras rather than a new column because the mirror tables are being migrated to first-class Sentry run models soon; adding a column here would be throwaway. Co-Authored-By: Claude <noreply@anthropic.com>
| eligible_projects, organization, resolved_max_candidates | ||
| ) | ||
| if agent_run_id is not None: | ||
| run.update(extras={**run.extras, "agent_run_id": agent_run_id}) |
There was a problem hiding this comment.
I'll add a real FK once our other Seer models are finally added.
Stacked on top of #113491. Add an internal, direct-link-only page at `/organizations/:orgSlug/seer/workflows/` that lists historical Night Shift runs for the current org. Each row expands in place to show the issues the run processed (group, action taken, Seer run id) plus any run-level error message. Not linked from any nav — it is only reachable by typing the URL. Orgs without the `organizations:seer-night-shift` feature flag see a generic "retry" error state since the endpoint returns 404, which is sufficient for an internal page. Uses the existing `SimpleTable` primitive for the list so the row, header, and grid-template widths stay consistent with the rest of Sentry. The nested issues drilldown uses a plain HTML table with fixed widths to keep it compact inside the expanded row. Refs #113491 --------- Co-authored-by: Claude <noreply@anthropic.com>

Add a new organization-scoped endpoint at
/api/0/organizations/{organization_id_or_slug}/seer/workflows/that returnspaginated
SeerNightShiftRunrows with nestedSeerNightShiftRunIssuerecords for the requesting org.
This is the backend side of an internal, direct-link-only page for viewing
historical Night Shift workflow runs. Split from the frontend change per
the "backend and frontend are not atomically deployed" rule in
AGENTS.md—land this first, the route/view PR will follow.
The endpoint:
OrganizationEndpointwith theorg:readscope, so it is scoped tothe current org and honors existing permission checks.
organizations:seer-night-shiftfeature flag andreturns 404 when the flag is off (matches the flag's existing
api_expose=Falsebehavior so the endpoint is effectively invisible toorgs without Night Shift).
-date_addedand paginates viaOffsetPaginator.The serializer bulk-fetches issues in
get_attrskeyed byrun_idtoavoid N+1 when listing runs with their nested issues.