fix(mcp): map HTTP 4xx auth errors to non-retryable McpError::HttpAuth#3587
Merged
fix(mcp): map HTTP 4xx auth errors to non-retryable McpError::HttpAuth#3587
Conversation
HTTP 401/403/404/410/422 responses from remote MCP endpoints were
previously wrapped into McpError::Connection, which is classified as
retryable (McpErrorCode::Transient). This caused up to 47 s of
exponential-backoff delay on startup when bearer tokens or credentials
were misconfigured.
Add McpError::HttpAuth { server_id, status: u16 } mapped to
McpErrorCode::AuthFailure (is_retryable = false). Replace the generic
map_err in connect_url / connect_url_with_headers with a typed
classify_connect_error helper that downcasts StreamableHttpError and
emits McpError::HttpAuth for non-retryable 4xx codes. Statuses 408,
425, and 429 remain McpError::Connection (retryable).
Adds 18 unit tests covering all non-retryable and retryable paths.
OAuth connection paths are tracked as a follow-up in #3586.
Closes #3579
ba845ce to
90b40d7
Compare
4 tasks
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
McpError::Connection(retryable), causing up to 47 s of backoff delay when credentials were misconfiguredMcpError::HttpAuth { server_id, status: u16 }mapped toMcpErrorCode::AuthFailure(is_retryable = false)map_errinconnect_url/connect_url_with_headerswithclassify_connect_errorhelper that downcastsStreamableHttpErrorand emitsMcpError::HttpAuthfor non-retryable 4xxMcpError::Connection(retryable)Test plan
cargo nextest run -p zeph-mcp --lib— 453 tests passcargo clippy --workspace -- -D warnings— cleancargo +nightly fmt --check— cleanauth failedlog, no retriesFollow-up
OAuth handshake paths (
connect_url_oauth,complete_oauth) tracked in #3586.Closes #3579