fix(seer): Propagate Explorer failure reasons - #122969
Open
gricha wants to merge 1 commit into
Open
Conversation
gricha
marked this pull request as ready for review
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 |
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preserve
timeoutandstalledfailure 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.