Skip to content

fix!: preserve OAuth discovery transport errors - #1069

Merged
DaleSeo merged 2 commits into
mainfrom
fix/oauth-discovery-box-error
Jul 28, 2026
Merged

fix!: preserve OAuth discovery transport errors#1069
DaleSeo merged 2 commits into
mainfrom
fix/oauth-discovery-box-error

Conversation

@DaleSeo

@DaleSeo DaleSeo commented Jul 28, 2026

Copy link
Copy Markdown
Member

Motivation and Context

OAuth metadata discovery previously converted transport failures into a successful fallback path, hiding actionable causes such as connection and certificate errors. This PR reports those failures with the discovery URL and complete source chain while retaining fallback behavior for valid non-matching discovery responses.

PR #1028 identified this through a concrete failure: using the Linear MCP server from a node:22-bookworm-slim container without CA certificates made the server appear not to support OAuth, while the underlying TLS error was discarded. This PR retains the original intended semantics: transport failures and HTTP 5xx responses stop discovery and surface the cause, while recognized non-success responses can still fall through to other discovery candidates.

Because this work already changes error propagation and v3 is approaching, this is the right point to settle the public API before it becomes stable. Rather than expand the public OAuthHttpClientError wrapper with separate constructors for messages and source errors, it becomes a domain-specific alias for Box<dyn Error + Send + Sync>. This matches existing SDK error aliases, lets custom clients propagate native errors with ?, and confines the concrete compatibility wrapper required by oauth2 to the private implementation.

How Has This Been Tested?

Added coverage

Breaking Changes

OAuthHttpClientError changes from a public struct with an OAuthHttpClientError::new constructor to Box<dyn Error + Send + Sync>. Custom OAuthHttpClient implementations should return their native errors with .into() or box them directly.

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

@github-actions github-actions Bot added T-documentation Documentation improvements T-core Core library changes T-transport Transport layer changes labels Jul 28, 2026
Let custom OAuth HTTP clients preserve native error types and source chains
while keeping the type-erased boundary explicit in the public API.

BREAKING CHANGE: OAuthHttpClientError is now a boxed error alias; custom
clients should return native errors with .into() or box them directly.
@DaleSeo
DaleSeo force-pushed the fix/oauth-discovery-box-error branch from a7918b5 to 86a3c63 Compare July 28, 2026 14:21
@DaleSeo
DaleSeo marked this pull request as ready for review July 28, 2026 14:25
@DaleSeo
DaleSeo requested a review from a team as a code owner July 28, 2026 14:25
@DaleSeo DaleSeo self-assigned this Jul 28, 2026
@DaleSeo DaleSeo changed the title fix(auth): preserve OAuth discovery transport errors fix!: preserve OAuth discovery transport errors Jul 28, 2026
@@ -2525,37 +2541,33 @@ impl AuthorizationManager {
discovery_url.set_fragment(None);
discovery_url.set_path(&candidate_path);
if let Some(resource_metadata_url) =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to handle the error case here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error case is intentionally propagated by ?. I had the same question in #1028 (comment).

@DaleSeo
DaleSeo requested a review from alexhancock July 28, 2026 15:19
@DaleSeo
DaleSeo merged commit 0dea39d into main Jul 28, 2026
22 checks passed
@DaleSeo
DaleSeo deleted the fix/oauth-discovery-box-error branch July 28, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-documentation Documentation improvements T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants