getsentry / getsentry/sentry

Retrying integration setup after a validation error causes 500

Open
#124,126 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: Integrations
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

  1. 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
Image Image
  1. 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")
Image Image

Diagnosis

  • api_advance() increments step_index before api_finish_pipeline() runs.
  • api_finish_pipeline() returns a PipelineStepResult.error(...) on a validation failure but does not roll back step_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's get_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.

--

View Junior Session [Sentry]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.