fix(auth): disambiguate auth-denied vs missing component messages#4165
Merged
Conversation
#4054) 🤖 Generated with Claude Code
This comment was marked as spam.
This comment was marked as spam.
a6e9d35 to
774ab2c
Compare
jlowin
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When component-level
auth=denies access to a tool, resource, or prompt,get_tool()/get_resource()/get_prompt()swallow theAuthorizationErrorand returnNone.AuthMiddlewarethen can't tell "doesn't exist" apart from "exists but you can't see it", and it picked the worst of both: it told the caller the component was not found. A user who genuinely lacks access would chase a phantom missing-tool problem, while a global-auth denial on the very same component reports "insufficient permissions" — the two paths gave contradictory stories for the same underlying cause.This changes the three messages to
not found or not authorized. The wording is deliberately ambiguous: it stops misleading authorized-but-mistaken users without disclosing the existence of components to callers who aren't allowed to see them (the anti-enumeration property some deployments rely on). The misleading inline comments claimingget_*"raises if unauthorized" are corrected to document the realNone-collapsing behavior.Addresses Bug 1 of #4054. Bugs 2–4 are out of scope here (Bug 4 is handled in #4078).