feat(keycardai-oauth)!: pass error context through AccessContext.access(), rename to get_resource_error#114
Merged
Conversation
…ss(), rename to get_resource_error
ResourceAccessError is now populated with resource, error_type
('global_error' | 'resource_error' | 'missing_token'), available_resources,
and error_details at the three throw sites in AccessContext.access(). The
constructor already accepted these args; this fills the call sites so
middleware can surface which resource failed and why.
Also rename get_resource_errors -> get_resource_error. Plural method name
with a singular return shape was misleading.
Companion to keycardai/typescript-sdk#19 (TS commit 317a38b).
Addresses review feedback from @jerriclynsjohn.
BREAKING CHANGE: AccessContext.get_resource_errors renamed to
AccessContext.get_resource_error.
… to match keycardai-oauth Mirrors the keycardai-oauth rename in the fastmcp provider's parallel AccessContext implementation. Keeps the two surfaces aligned for users who consume both directly. BREAKING CHANGE: AccessContext.get_resource_errors renamed to AccessContext.get_resource_error.
📦 Release PreviewThis analysis shows the expected release impact: 📈 Expected Version Changes📋 Package Details[
{
"package_name": "keycardai-oauth",
"package_dir": "packages/oauth",
"has_changes": true,
"current_version": "0.11.0",
"next_version": "0.12.0",
"increment": "MINOR"
},
{
"package_name": "keycardai-fastmcp",
"package_dir": "packages/fastmcp",
"has_changes": true,
"current_version": "0.2.0",
"next_version": "0.3.0",
"increment": "MINOR"
}
]📝 Changelog PreviewThis comment was automatically generated by the release preview workflow. |
Four changes based on code review of the access() rename / rich-error PR: 1. available_resources semantics: for global_error and resource_error, details["available_resources"] is now None instead of []. The empty-list default implied "zero resources available" rather than "field not applicable". Only the missing_token path should carry a list. 2. README sweep for get_resource_error rename: four docs files still called get_resource_errors (plural) after the rename — added to PR #114 scope to prevent AttributeError for any user following those examples. 3. Test assertion fixes: resource_error and global_error tests now assert available_resources is None. missing_token test uses set comparison to avoid fragility when token registration order varies. 4. fastmcp unit tests: AccessContext.access() in provider.py is an independent implementation with the same three error paths. Add tests/test_access_context.py mirroring the oauth test file.
📦 Release PreviewThis analysis shows the expected release impact: 📈 Expected Version Changes📋 Package Details[
{
"package_name": "keycardai-oauth",
"package_dir": "packages/oauth",
"has_changes": true,
"current_version": "0.11.0",
"next_version": "0.12.0",
"increment": "MINOR"
},
{
"package_name": "keycardai-fastmcp",
"package_dir": "packages/fastmcp",
"has_changes": true,
"current_version": "0.2.0",
"next_version": "0.3.0",
"increment": "MINOR"
}
]📝 Changelog PreviewThis comment was automatically generated by the release preview workflow. |
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.
Summary
Companion to keycardai/typescript-sdk#19. Brings python-sdk's
AccessContext.access()to the same shape, addressing review feedback from @jerriclynsjohn.Two changes:
AccessContext.access()now passes error context toResourceAccessError. The constructor (exceptions.py:251-321) already acceptedresource,error_type,available_resources, anderror_details. The three throw sites inaccess()were callingResourceAccessError()with no args, throwing the context away. They now populate it so middleware can read those attributes (and thedetailsdict on the baseOAuthServerError) to surface which resource failed and why.Rename
get_resource_errors→get_resource_erroron bothkeycardai.oauth.server.access_context.AccessContextand the parallelkeycardai.fastmcp.provider.AccessContext. Plural method name with a singular return shape was misleading. Breaking on a pre-1.0 API.Test plan
cd packages/oauth && uv run pytest— 221 passed (6 newtest_access_context.pycases for the rich-error contract; oauth had no direct AccessContext tests before)cd packages/fastmcp && uv run pytest— 51 passedcd packages/mcp && uv run pytest— 532 passed (16 interactive skips)Related
317a38bBREAKING CHANGE:
AccessContext.get_resource_errorsrenamed toAccessContext.get_resource_erroron bothkeycardai-oauthandkeycardai-fastmcp.