Skip to content

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

Closed
systemblueio wants to merge 1 commit into
modelcontextprotocol:mainfrom
systemblueio:fix/internalerror-decode-message
Closed

fix: preserve internal error message when decoding from a peer#248
systemblueio wants to merge 1 commit into
modelcontextprotocol:mainfrom
systemblueio:fix/internalerror-decode-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.

Co-Authored-By: Claude <noreply@anthropic.com>
@systemblueio

Copy link
Copy Markdown
Author

Superseded by #249 (same fix, cleaner commit history).

@systemblueio systemblueio deleted the fix/internalerror-decode-message branch June 7, 2026 15:16
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