Retrying integration setup after a validation error causes 500
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 44.8k
- Forks
- 4.9k
- Avg merge
- 21h 23m
- Merged PRs (30d)
- 607
Description
Summary
Retrying an API-driven integration setup pipeline (e.g. Claude Agent) after a validation failure returns a generic 500 Internal Error instead of a clean validation message, because the pipeline's step index has already advanced past the retryable step.
Steps to reproduce
POST /api/0/organizations/{org}/pipeline/integration_pipeline/with an invalid API key for the Claude Agent (claude_code) integration → correctly returns 400 with"Invalid Anthropic API key. Please check your credentials."or via web UI navigate to Settings -> Integrations -> Claude Agent -> Add Agent, intentionally enter invalid API key
- Retry the same request (same pipeline session, different key) → returns 500 with
{"detail": "Internal Error", "errorId": "..."}instead of a validation error. Or in web UI click "Continue" one more time (not "Start over")
Diagnosis
api_advance()incrementsstep_indexbeforeapi_finish_pipeline()runs.api_finish_pipeline()returns aPipelineStepResult.error(...)on a validation failure but does not roll backstep_index.- On retry within the same session, the pipeline resolves
api_steps[step_index], which is now out of range for providers with a single API step (e.g. Claude Agent'sget_pipeline_api_steps()returns only[ClaudeCodeApiKeyApiStep()]), producing an unhandled exception and generic 500.
Reproduced against org sentry-sn0 with errorId a833faf7eb9f4c81821613e43e14c676.
Impact
Low severity — reloading the integration setup page before retrying avoids the bug — but the resulting 500/Internal Error is confusing for customers troubleshooting a bad API key.
via Igor M.
--
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/sentry/pipeline/base.py around api_advance() and src/sentry/integrations/pipeline.py around api_finish_pipeline(), then inspect the Claude Agent provider's get_pipeline_api_steps() behavior. Reproduce the POST with an invalid key, retry it with a different key in the same session, and verify the retry returns the clean validation error rather than a generic 500.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100