Skip to content

fix(integrations): make issue link retries safe - #124069

Merged
betegon merged 12 commits into
masterfrom
bt/issue-link-idempotency
Sep 25, 2026
Merged

betegon merged 12 commits into
masterfrom
bt/issue-link-idempotency

Conversation

@betegon

@betegon betegon commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Retrying native issue linking currently repeats provider comments before rejecting the duplicate; App linking can also replace the group's existing association. This makes retries predictable and adds an opt-in guard for App callers that know the expected target.

  • Native PUT returns 200 for an existing link and 201 for a new link, without adding fields to the response body. Repeated links skip provider comments and activity. PUT and DELETE use one lock helper keyed by organization, integration, and external issue key; activity and action-log publication stay inside that lock.
  • App actions accept an optional expectedExternalIssueUrl query parameter for action=link. An exact existing match returns 200 without a callback; a newly created association returns 201. A different association or callback URL returns 409, and guarded persistence never replaces a concurrent association. Omitting the parameter preserves existing replacement behavior and HTTP 200.
  • Native and group-scoped App DELETE return 204 when the association is already absent. Installation-scoped App DELETE retains its existing authorization and 404 when the association is absent at the initial lookup. It acquires the same App lock in the cell service and rechecks the scoped association before publishing or deleting; if another request already removed the association after authorization, it returns 204 without publishing another action. Lock contention returns 409.

OpenAPI documents these responses, including the installation DELETE's legacy schema. Paths, scopes, and issue resolution state are unchanged. Remote callback effects cannot be rolled back after a conflicting response, and this does not promise exactly-once execution across crashes or lock expiry.

Uses the merged experimental App API schemas and URL-linking support for Jira, GitHub/GitHub Enterprise, GitLab, Bitbucket, and Azure DevOps. App form/URL resolution remains deferred.

Validation: targeted native endpoint/action-log, App action/delete, all-silo cell service, and API schema tests passed. Regression checks cover locks held during native activity/publication, installation DELETE contention without deletion or publication, and a concurrent disappearance after authorization returning 204 while initial absence retains 404. Lint, targeted mypy, OpenAPI generation, generated response-schema assertions, and all 187 API examples passed. Provider calls are mocked; live provider behavior and the full repository suite were not tested.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 10, 2026
@betegon
betegon marked this pull request as ready for review September 14, 2026 14:23
@betegon
betegon requested review from a team as code owners September 14, 2026 14:23
@betegon
betegon force-pushed the bt/issue-link-idempotency branch from eabcbb8 to ec98e5b Compare September 14, 2026 19:59
@betegon
betegon force-pushed the bt/issue-link-idempotency branch from ec98e5b to 2d5ebee Compare September 16, 2026 08:22

@sfanahata sfanahata 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.

Does adding changed to the shared PlatformExternalIssueSerializerResponse expose that field in the generated schemas for all types of endpoints that use the response type, even though some of those endpoints do not return it? Do we want that, or is there a way to narrow only the relevant endpoints to show changed?

@betegon

betegon commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

@sfanahata goo catch!

fixed it so changed now lives in an actions-specific response type with its own schema component. The shared type stays unchanged

@betegon
betegon requested a review from cvxluo September 25, 2026 17:08

@cvxluo cvxluo 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.

bots tell me that

class SentryAppInstallationExternalIssueDetailsEndpoint(ExternalIssueBaseEndpoint):
might also need a lock

otherwise looks good, don't see any blocking issues

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

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 840570f. Configure here.

@betegon
betegon merged commit da16b1a into master Sep 25, 2026
66 of 67 checks passed
@betegon
betegon deleted the bt/issue-link-idempotency branch September 25, 2026 20:21
betegon added a commit to getsentry/toolkit that referenced this pull request Sep 28, 2026
Add catalog-only `link_issue` and `unlink_issue` so agents can associate
existing external tickets or GitHub pull requests with a Sentry issue,
then remove those references by URL. Both use the existing MCP API
client; this does not depend on `@sentry/api` or change `update_issue`.

Native integrations receive the full URL for backend parsing. Sentry
Apps use their installed issue-link form and guarded callback, so
retries return the existing association and a different App link must be
explicitly unlinked first. Both tools require the `triage` skill with
`event:write` and `org:read`, preserving organization, project, and
region constraints.

This requires the backend URL-linking changes and the retry contract
from getsentry/sentry#124069. App support covers single-value
select/text forms and requires the provider's exact canonical URL.
Unlink uses the existing association-ID DELETE contract; it does not
delete the external ticket or resolve the Sentry issue.

Fixes #228

Related: #1257 tracks creating new external tickets, and #1095 covers
richer integration metadata. Those capabilities are outside this PR;
only #228 is resolved here.

---------

Co-authored-by: GPT-5 Codex <[email protected]>
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: betegon <[email protected]>
Co-authored-by: Codex (GPT-6) <[email protected]>
betegon added a commit to getsentry/sentry-changelog that referenced this pull request Oct 8, 2026
Adds one changelog entry,
`content/changelog/2026-10-sentry-mcp-2026-09-15-to-2026-09-30.md` (slug
`sentry-mcp-2026-09-15-to-2026-09-30`, proposed date 2026-10-01). It
covers changes that reached the hosted MCP server (mcp.sentry.dev)
during this period. The entry is `published: true`, so it goes live only
after a human merges this PR and the sync runs.

## What the article says

- **Alerts and Metric Monitors**: 11 new or expanded catalog tools to
create, edit, delete, and inspect Alerts and Metric Monitors. Writes
need the **Manage Projects & Teams** skill and the new `alerts:write`
OAuth scope, so existing connections must re-authorize.
- **Issue linking**: `link_issue` and `unlink_issue` (Triage skill).
- **Improvements**: suspect commit in `get_issue_details`; cursor
pagination for `find_organizations`, `find_projects`, and `find_teams`.
- **Fixes**: `search_events` query generation, 404s for legacy
mixed-case slugs, Codex OAuth, `get_alert_options` with Sentry Apps,
null bytes in `update_issue` reasons, and a mcp.sentry.dev crash without
WebAssembly.
- **stdio MCP server**: `@sentry/mcp-server` 0.40.0–0.42.0 is described
separately (alert tools, single-tenant host fixes, Seer off by default
on self-hosted). Those npm versions do not include issue linking,
suspect commits, pagination, or the `search_events` fixes.

**Excluded** (no verified direct user effect): CI and risk labeling,
evals, trace sampling, SDK and dependency bumps, internal logging and
telemetry, MCP Registry release automation, and release merges.

## Attribution notes

Credits come from GitHub PR authors and GitHub-resolved commit
coauthors. Bots and AI bylines (Codex, Claude, GPT) are excluded.
- #1326 and #1345 were authored by `sentry[bot]` (Seer Autofix). They
are linked without a human credit.
- #1328 was authored by `sentry-junior[bot]`. David Cramer is credited
as "with" because GitHub resolves him as a commit coauthor.
- Miguel Betegón is credited as a coauthor where GitHub lists him on
external PRs (#1027, #1339, #1319, #1346).

## Validation

- `pnpm changelog:validate`: 11 files valid; `pnpm lint`, `pnpm exec tsc
--noEmit`, and all 41 tests pass.
- The article body and summary compile with the app's MDX options. Every
contributor credit and frontmatter field is preserved. All 21 pull
request links point directly to GitHub.
- Verified the deployed preview in Chrome: benefits-first opening,
simplified alert/monitor descriptions, prominent reauthorization note,
separate fixes, and the stdio package section render correctly. Inline
code remains free of decorative backticks.
- Database sync was not run. The linked PR pages were not individually
checked in the browser.
- **Deployment evidence is limited to GitHub Actions** (the `Deploy to
Cloudflare` workflow). It cannot rule out out-of-band Cloudflare
deployments or rollbacks.
- `link_issue` depends on getsentry/sentry#124069, which merged on
2026-09-25. Its deployment to sentry.io was not independently verified.

## Coverage (proposed, not published)

```yaml
product: mcp
source_repository: getsentry/sentry-mcp
baseline_sha_exclusive: 55a62a2b7dfde35df6aa3e3e66542bbfd34362da
endpoint_sha_inclusive: aef89da473e295f32d5991789dcbd8111aa8e85f
coverage_utc: 2026-09-15T00:00:00Z..2026-09-30T15:04:45Z
non_merge_commits: 36
baseline_deploy: https://github.com/getsentry/sentry-mcp/actions/runs/34853993110
endpoint_deploy: https://github.com/getsentry/sentry-mcp/actions/runs/36733973234
compare: getsentry/toolkit@55a62a2...aef89da
```

The baseline was the production revision at 2026-09-15 00:00 UTC
(deployed 2026-09-14). The endpoint was the last production deploy. Both
runs passed the canary and production deploy and smoke-test steps, and
neither rolled back. Since 2026-09-29, `deploy.yml` has been disabled
(`if: false`) during the CLI and docs import. The latest `main`
(`d929248`) was skipped and is not deployed, so the imported CLI history
is not in this range.

<div><a
href="https://cursor.com/agents/bc-317ba004-3917-4df5-9b13-58b7ac795e83?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/automations/ceb3f70f-b760-11f1-bb68-864e54d14197"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/view-automation-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/view-automation-light.png"><img
alt="View Automation" width="141" height="28"
src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: betegon <[email protected]>
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.

3 participants