Skip to content

feat(seer): Add workflows list endpoint for Night Shift runs#113491

Merged
chromy merged 5 commits into
masterfrom
trevor-e/feat/seer-workflows-api
Apr 21, 2026
Merged

feat(seer): Add workflows list endpoint for Night Shift runs#113491
chromy merged 5 commits into
masterfrom
trevor-e/feat/seer-workflows-api

Conversation

@trevor-e

Copy link
Copy Markdown
Member

Add a new organization-scoped endpoint at
/api/0/organizations/{organization_id_or_slug}/seer/workflows/ that returns
paginated SeerNightShiftRun rows with nested SeerNightShiftRunIssue
records 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:

  • Uses OrganizationEndpoint with the org:read scope, so it is scoped to
    the current org and honors existing permission checks.
  • Is gated behind the organizations:seer-night-shift feature flag and
    returns 404 when the flag is off (matches the flag's existing
    api_expose=False behavior so the endpoint is effectively invisible to
    orgs without Night Shift).
  • Orders by -date_added and paginates via OffsetPaginator.

The serializer bulk-fetches issues in get_attrs keyed by run_id to
avoid N+1 when listing runs with their nested issues.

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>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 20, 2026
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 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 #discuss-dev-infra channel.

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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/sentry/api/serializers/models/seer_night_shift_run.py
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>
@trevor-e
trevor-e force-pushed the trevor-e/feat/seer-workflows-api branch from a9c5b34 to fba8f91 Compare April 20, 2026 23:08
@trevor-e
trevor-e marked this pull request as ready for review April 20, 2026 23:23
@trevor-e
trevor-e requested review from a team as code owners April 20, 2026 23:23
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})

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a real FK once our other Seer models are finally added.

@chromy chromy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chromy
chromy merged commit 11c20bb into master Apr 21, 2026
57 checks passed
@chromy
chromy deleted the trevor-e/feat/seer-workflows-api branch April 21, 2026 10:28
chromy pushed a commit that referenced this pull request Apr 21, 2026
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>
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants