Skip to content

fix: preserve internal error message when decoding from a peer#249

Closed
systemblueio wants to merge 1 commit into
modelcontextprotocol:mainfrom
systemblueio:fix/preserve-internal-error-message
Closed

fix: preserve internal error message when decoding from a peer#249
systemblueio wants to merge 1 commit into
modelcontextprotocol:mainfrom
systemblueio:fix/preserve-internal-error-message

Conversation

@systemblueio

Copy link
Copy Markdown

What was wrong

MCPError's decoder dropped the message for -32603. That case passed nil as the detail fallback, while parseError, invalidRequest, methodNotFound, and invalidParams all fall back to the message. So a peer sending {"code":-32603,"message":"..."} with no data.detail decoded to .internalError(nil), losing the message that the other standard errors keep.

Fix

One line: -32603 now uses unwrapDetail(message), matching the other standard JSON-RPC error cases.

Verification

Added a decode test in ResponseTests that fails on main and passes with the change. Full suite green (swift test, 552 tests).

MCPError's decoder dropped the message for code -32603 by passing nil as
the detail fallback, while every other standard JSON-RPC error case falls
back to the message. A peer sending {"code":-32603,"message":"..."} with
no data.detail decoded to .internalError(nil), losing the message. Use the
message fallback so internalError matches the other cases.
@systemblueio systemblueio closed this by deleting the head repository Jun 9, 2026
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