Skip to content

fix(mcp): Tell the agent a 403 without a scope challenge won't succeed on retry - #2422

Open
pcbeingused333 wants to merge 1 commit into
getsentry:mainfrom
pcbeingused333:fix/c4568-403-permission
Open

pcbeingused333 wants to merge 1 commit into
getsentry:mainfrom
pcbeingused333:fix/c4568-403-permission

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #2356

When Sentry answers 403 without an insufficient_scope challenge (the account lacks the role or project access, for example search_issues with a project the caller's teams can't reach), formatErrorForUser sent it through the generic Input Error template, which ends with "You may be able to resolve the issue by addressing the concern and trying again." The 403 comes from the account's access, not from the input, so the agent retries a call that cannot succeed and never tells the user to ask for access.

#2222 handled only the scope-challenge case. This adds findPermissionDeniedError, which finds any non-scope ApiPermissionError on the error or within its cause chain (so it also covers tools that rewrap it as a UserInputError). formatErrorForUser now returns a Permission Denied message that keeps the API detail, says retrying the same call will not help, and points to an organization Owner or Manager or a different organization or project. The scope-challenge path is unchanged and still checked first; both finders share one cause-walking helper.

Tests: the existing "keeps the input error template for a 403 without a challenge" case now expects the new message, and a new case covers the rewrapped UserInputError. Both fail on main and pass with the change; the full packages/mcp-core suite passes.

This change was prepared, and the tests above were run, with the assistance of an AI coding tool.

…d on retry

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pcbeingused333
pcbeingused333 requested a review from a team as a code owner November 19, 2026 07:09
@vercel

vercel Bot commented Nov 19, 2026

Copy link
Copy Markdown

@pcbeingused333 is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A 403 without a scope challenge still tells the agent to retry

1 participant