Visitar URL original
fix(auth/http): retry transient fetch failures once within an overall deadline by Shanmukh-l33t · Pull Request #1847 · modelcontextprotocol/registry · GitHub
Skip to content

fix(auth/http): retry transient fetch failures once within an overall deadline - #1847

Merged
rdimitrov merged 2 commits into
modelcontextprotocol:mainfrom
Shanmukh-l33t:fix-1625
Nov 12, 2026
Merged

rdimitrov merged 2 commits into
modelcontextprotocol:mainfrom
Shanmukh-l33t:fix-1625

Conversation

@Shanmukh-l33t

@Shanmukh-l33t Shanmukh-l33t commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

HTTP authentication currently fails on the first verification-fetch error. This change allows one retry for transient connection/read failures and HTTP 408, 429, or 5xx responses.

The fetch has a 15-second overall deadline covering both attempts, body reads, and the 500 ms backoff. Each attempt retains the existing 10-second limit, subject to the remaining overall budget and any earlier caller deadline. A first-attempt timeout therefore leaves about 4.5 seconds for the retry.

TLS certificate verification failures, blocked addresses, nonexistent domains, redirects, other 4xx responses, and oversized bodies fail immediately. TLS verification, DNS/IP pinning and address restrictions, the 4096-byte response limit, signature verification, and namespace permissions remain in place. No new metrics are added.

Related to #1625. This improves resilience but does not establish or conclusively fix the historical connectivity failure reported there.

Rebased onto current main (899011e), preserving the multiple-proof and key-retirement documentation.

Validation:

  • go test -race ./internal/api/handlers/v0/auth/... ./internal/auth/... passed.
  • make lint validate passed with golangci-lint v2.14.0.
  • Tests cover transient connection/status recovery, two-attempt exhaustion, the production 15-second deadline, earlier caller deadlines, cancellation during backoff/body reads, recovery after an attempt timeout, TLS/address/DNS permanent failures, truncated and oversized bodies, redirects after a retry, and successful signature-based token exchange after recovery.
  • CI Pipeline passed on 2fdcd6230034285bfa4bd27fed355dda9d0f394a: build/lint/validation/vulnerability checks, full tests, and deployment configuration tests.

Shanmukh-l33t and others added 2 commits November 12, 2026 23:59
The well-known key fetch was a single attempt, so one transient
unreachable moment — a dial timeout, a reset connection, a CDN edge
answering 5xx — failed the whole HTTP login with 401 even though the
endpoint answers moments later (modelcontextprotocol#1625).

FetchKey now retries transient failures (transport errors and HTTP
408/429/5xx) up to 3 attempts with 500ms backoff, bounded by the
caller's context. Permanent failures (other 4xx, redirects, oversized
bodies) still fail immediately on the first attempt. When every attempt
fails, the error reports how many attempts were made so fetch problems
can be distinguished from key problems.

The documented fetch contract in authentication.mdx is updated
accordingly.
@rdimitrov rdimitrov changed the title fix(auth/http): retry transient verification fetch failures fix(auth/http): retry transient fetch failures once within an overall deadline Nov 12, 2026

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the bounded retry behavior and security implications. One retry shares a 15-second overall deadline, with cancellation and permanent failures handled promptly. Signature verification, namespace permissions, TLS verification, address restrictions, redirect refusal, and response-size limits remain intact. Auth race tests, additional adversarial checks, lint/validation, and full CI pass. The bounded increase in unauthenticated fetch work is acceptable for the observed transient-failure cases.

@rdimitrov
rdimitrov merged commit 87054b5 into modelcontextprotocol:main Nov 12, 2026
3 checks passed
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.

2 participants