Repository navigation
fix(mcp): Check an issue an ID alone names against the session's project - #2527
sentry-junior[bot] wants to merge 5 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
BYK
left a comment
There was a problem hiding this comment.
Follow-up: events, traces and replays fetched by an opaque ID (event view , trace view , replay view ) are not checked against the session's project yet. This PR covers issue lookups only (Feedback included).
We should do this right away in a follow up PR>
The SDK's fake process started with `exitCode: 0`. Stricli records a failure with `exitCode ??= code`, which a 0 swallows, so `sdk.run()` resolved `undefined` for a command that failed, such as one whose API request returned 404. The exit code now starts unset, as on Node's own `process`. Ported from the same fix in #1922, which the scope checks in this stack need: a refused request has to reach the caller as an error. Refs #2237 Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
In a project-scoped `sentry mcp --commands` session, the command surface checks the targets a call names, but a numeric issue ID, an issue URL, a share link, a selector (`@latest`), or search text names no project, so `issue view 12345` or `issue resolve 12345` reached an issue in another project of the same organization. The stdio runner now passes `limitToTarget` to the CLI SDK, which makes the session's org and project a limit instead of a default. Issue lookups check the issue they find before a command reads or changes it: `getIssueInOrg` and `getIssueByShortId` refuse another organization before the request and another project after it, the issue and Feedback selectors and issue search look only in the session's project, and `event view` checks a numeric issue before it reads the issue's events. Fixes #2237 Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
`limitToTarget` now defaults to `true`: with `org` (and `project`) set,
`createSentrySDK()` refuses an issue outside them, including one an ID
alone names (`issue view 12345`, `@latest`). Pass `limitToTarget: false`
to use `org` and `project` only as defaults, as before.
`sentry mcp --commands` still passes `limitToTarget: true` explicitly, so
its sessions don't depend on the default.
BREAKING CHANGE: `createSentrySDK({ org, project })` no longer reads or
changes issues outside `org`/`project`. Callers that use them only to skip
typing the slug and look up issues elsewhere must pass
`limitToTarget: false`.
Refs #2237
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
d76215d to
25e63d8
Compare
|
This PR is too large for Bugbot to review. It changes 50,402 lines and 3,791,240 characters. Split the change into smaller pull requests to get a review. |
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c77ff29. Configure here.
In a project-scoped session, the issue search runs in that project alone, so the no-match and several-match errors name it, and their recovery command lists that project's issues.

Refs #2237. Based on
main.In a project-scoped
sentry mcp --commandssession (acme/web), the command surface checks the targets a call names. Some identifiers name no project: a numeric issue ID, an issue URL, a share link, a selector such as@latest, or search text. The session's org and project reached the CLI only as defaults (SENTRY_ORG/SENTRY_PROJECT), so nothing compared the issue the CLI found with the session. Examples that got through:issue view 12345read an issue in another project.issue resolve 12345changed an issue in another project.issue view @latestandfeedback view @latestpicked the newest issue in the whole organization.event view https://acme.sentry.io/issues/12345/read another project's events.As proposed in the issue, the CLI now checks the issue after it looks it up and before a command reads or changes anything.
Changes
SentryOptions.limitToTargetmakesorg/projecta limit instead of a default. It defaults totrue, andlimitToTarget: falseopts out. The SDK passes it to the invocation as the internal env varsSENTRY_CLI_SCOPE_ORG/SENTRY_CLI_SCOPE_PROJECT. Thesentry mcp --commandsrunner wiring that sets it now lives in fix(mcp): Limit sentry mcp --commands sessions to their target #2554.lib/target-scope.tsrefuses an issue in another organization or project with aResolutionError. In a project scope, an issue whose project is unknown is refused too.getIssueInOrgandgetIssueByShortIdrefuse another organization before the request and another project after it. Every lookup by ID goes through these two: numeric,<org>/<id>, URL, share link, short ID and alias.findSelectorIssue, issue search and the Feedback@latestselector look only in the session's project, then check the result.event view. For a numeric issue or an issue URL, it checks the issue before it reads the issue's events. Before, its project lookup was best-effort, and it was skipped when the call named a project.library-usage.md) now describes the limit. The--commandsnotes (docs/architecture/overview.md, mcp-coreconstraints.ts) now live in fix(mcp): Limit sentry mcp --commands sessions to their target #2554.Breaking change:
createSentrySDK({ org, project })callers now getorg/projectas a limit, not just a default, so a command that reaches another organization or project fails. PasslimitToTarget: falseto keep the old behavior.Follow-up: events, traces and replays fetched by an opaque ID (
event view <event-id>,trace view <trace-id>,replay view <replay-id>) are not checked against the session's project yet. This PR covers issue lookups only (Feedback included).via @BYK.
--
View Session [Sentry]