Skip to content

[Doc] Bound the token endpoint error docs to what sets the readers - #633

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:refine_the_token_endpoint_error_docs
Oct 26, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:refine_the_token_endpoint_error_docs

Conversation

@koic

@koic koic commented Oct 26, 2026

Copy link
Copy Markdown
Member

Motivation and Context

The "Token endpoint errors" section opens with "When a token exchange or refresh fails", but the readers it describes are set only when the token endpoint answers with a non-2xx response within the body cap: a transport failure, a body over the cap, and a 2xx response with a broken body all raise AuthorizationError with nil readers. The section also leaves unsaid that InvalidGrantError is chosen on the raw error while the error reader holds the sanitized value, so a code the server padded, "invalid_grant\n" say, reads back as error == "invalid_grant" yet raises AuthorizationError; a reader inferring the class from the reader would get it wrong. The section now states the condition and the distinction.
The sentence that other authorization failures have nil readers predates the authorization callback error of 1.7.0, which sets error and error_description with http_status left nil; the section now says so. A blank diagnostic field reads as nil as well, since the sanitizer strips it; the section says so too.

How Has This Been Tested?

Docs only. Both statements were checked against token_endpoint_error and bounded_request in lib/mcp/client/oauth/flow.rb.
The callback sentence was checked against authorization_response_error.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## Motivation and Context

The "Token endpoint errors" section opens with "When a token exchange or refresh fails", but the readers it describes
are set only when the token endpoint answers with a non-2xx response within the body cap: a transport failure, a body
over the cap, and a 2xx response with a broken body all raise `AuthorizationError` with `nil` readers. The section
also leaves unsaid that `InvalidGrantError` is chosen on the raw `error` while the `error` reader holds the sanitized
value, so a code the server padded, `"invalid_grant\n"` say, reads back as `error == "invalid_grant"` yet raises
`AuthorizationError`; a reader inferring the class from the reader would get it wrong. The section now states
the condition and the distinction.
The sentence that other authorization failures have `nil` readers predates the authorization callback error
of 1.7.0, which sets `error` and `error_description` with `http_status` left `nil`; the section now says so.
A blank diagnostic field reads as `nil` as well, since the sanitizer strips it; the section says so too.

## How Has This Been Tested?

Docs only. Both statements were checked against `token_endpoint_error` and `bounded_request` in
`lib/mcp/client/oauth/flow.rb`.
The callback sentence was checked against `authorization_response_error`.

## Breaking Changes

None.
@koic
koic merged commit f8fbeb7 into modelcontextprotocol:main Oct 26, 2026
11 checks passed
@koic
koic deleted the refine_the_token_endpoint_error_docs branch October 26, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant