Skip to content

v0.28.0 regression: DCR fails for issuers with non-root paths #5356

Closed

Description

@gkatz2

Bug description

After upgrading to v0.28.0, thv run cannot complete fresh OAuth client registration for remote MCP servers whose authorization server has a non-root issuer path (e.g., issuer https://example.com/oauth rather than https://example.com). The browser never opens and the workload never enters running state.

The regression fires only on fresh DCR: first-time setup, after thv rm + thv run, or when cached client credentials are invalidated. Workloads whose runconfigs still have a cached client_id are unaffected because DCR is skipped on that path, so users who upgrade without removing existing workloads may not notice the bug until something forces re-registration.

In practice this affects any RFC 8414 §3 compliant authorization server with a non-root issuer path, not just unusual multi-tenant IdPs. PR #5250 ("Migrate CLI OAuth flow to pkg/auth/dcr resolver") removed a fallback that the pre-existing discovery utility provided, and its docstring flagged this as a "known limitation of the option (b) migration."

Steps to reproduce

Use a remote MCP server whose authorization server has a non-root issuer path and serves its metadata at the RFC 8414 §3 host-root path (https://example.com/.well-known/oauth-authorization-server/oauth) but not at https://example.com/oauth/.well-known/openid-configuration. With no cached OAuth client credentials for the workload:

thv rm <server>
thv run <server> [...flags...]

Expected behavior

DCR completes, the OAuth browser flow opens, and the workload enters running state. This was the v0.27.x behavior.

Actual behavior

thv run exits before launching the browser:

Error: failed to restart workload <server>: failed to authenticate to remote server: remote authentication failed: dynamic client registration failed: dcr: metadata_discovery: discover authorization server metadata: fetch discovery document from "https://example.com/oauth/.well-known/openid-configuration": unexpected content-type "text/html"

The workload does not appear in thv ls. The corresponding workload log file contains the structured failure event:

{"level":"ERROR","msg":"dcr: resolve failed","step":"metadata_discovery","issuer":"https://example.com/oauth","error":"discover authorization server metadata: fetch discovery document from \"https://example.com/oauth/.well-known/openid-configuration\": unexpected content-type \"text/html\""}

The HTTP response from the OIDC issuer-suffix path varies by server (404, redirect, HTML, etc.); the resolver always names metadata_discovery as the failing step.

Environment (if relevant)

  • OS/version: macOS Darwin 25.3.0 / arm64
  • ToolHive version: v0.28.0 (commit 2ce3ef76ac17d53fa45564b847025d9518a45c34, official release binary)

Additional context

The new resolveDCRCredentials function at pkg/auth/discovery/discovery.go:741 builds a single discovery URL:

req.DiscoveryURL = strings.TrimRight(discoveredDoc.Issuer, "/") + "/.well-known/openid-configuration"

The pre-existing discoverOIDCEndpointsWithClientAndValidation at pkg/auth/oauth/oidc.go:114-149 tried both well-known variants (the OIDC issuer-suffix path AND the RFC 8414 §3 host-root path) and fell back from the first to the second. The new resolver only tries the first.

The redundant fetch exists because the resolver needs code_challenge_methods_supported to evaluate the S256 PKCE gate, and AuthServerInfo doesn't carry that field. The PR #5250 docstring identifies the architectural follow-up: "Threading code_challenge_methods_supported through AuthServerInfo (and updating every caller of ValidateAndDiscoverAuthServer) would close this loop and is the natural follow-up; it is out of scope for sub-issue 4b."

Workaround for users on v0.28.0: downgrade to v0.27.2.

Activity

  1. added
    bug
    go
    on May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationbuggooauth

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions