Skip to content

fix(seer): Propagate Explorer failure reasons - #122969

Open
gricha wants to merge 1 commit into
masterfrom
fix/seer-failure-reason-propagation
Open

fix(seer): Propagate Explorer failure reasons#122969
gricha wants to merge 1 commit into
masterfrom
fix/seer-failure-reason-propagation

Conversation

@gricha

@gricha gricha commented Aug 28, 2026

Copy link
Copy Markdown
Member

Preserve timeout and stalled failure reasons when Sentry parses Seer run state, allowing the Explorer chat API to expose the terminal cause to the frontend.

Seer begins emitting these reasons in getsentry/seer#7911, but Sentry's Pydantic boundary previously discarded the unknown field. The field remains optional for compatibility with older Seer responses. This unblocks the timeout recovery UI in #122934.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 28, 2026
@gricha
gricha marked this pull request as ready for review August 28, 2026 02:14
@gricha
gricha requested a review from a team as a code owner August 28, 2026 02:14
blocks: list[MemoryBlock]
status: Literal["processing", "completed", "error", "awaiting_user_input"]
updated_at: str
failure_reason: Literal["timeout", "stalled"] | None = None

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.

Bug: An unrecognized failure_reason from the Seer API will cause a ValidationError that is incorrectly handled as a 404 Not Found, masking the true error.
Severity: MEDIUM

Suggested Fix

Explicitly catch pydantic.ValidationError in the endpoint to handle this case separately from a generic ValueError. Alternatively, make the SeerRunState model more lenient by removing the strict Literal and allowing any string, to ensure forward compatibility with the Seer API.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/seer/agent/client_models.py#L267

Potential issue: The `SeerRunState` Pydantic model defines the `failure_reason` field
with a strict `Literal["timeout", "stalled"]`. If the external Seer API sends a new,
unrecognized failure reason, Pydantic will raise a `ValidationError` during response
parsing. Because Pydantic v1's `ValidationError` is a subclass of `ValueError`, this
exception is caught by a generic `except ValueError` block in the endpoint. This handler
incorrectly returns a 404 Not Found response, which makes it appear to the client that
the run does not exist, when it actually does. This masks the true error and leads to a
misleading state for the user.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant