Skip to content

mcp: preserve existing Content in SetError#864

Open
ravyg wants to merge 1 commit intomodelcontextprotocol:mainfrom
ravyg:fix/858-seterror-preserve-content
Open

mcp: preserve existing Content in SetError#864
ravyg wants to merge 1 commit intomodelcontextprotocol:mainfrom
ravyg:fix/858-seterror-preserve-content

Conversation

@ravyg
Copy link
Copy Markdown

@ravyg ravyg commented Mar 27, 2026

SetError now only populates the Content field when it has not already
been populated. This allows callers to provide a user-friendly message
while still recording the underlying error for middleware inspection
via GetError.

The len check (rather than nil check) ensures both nil and empty-slice
Content are treated as "not yet populated."

Fixes #858

SetError now only populates the Content field when it has not already
been populated (len check handles both nil and empty slice). This allows
callers to provide a user-friendly message while still recording the
underlying error for middleware inspection via GetError.

Fixes modelcontextprotocol#858
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.

SetError errors should not be automatically used as the text output for user

1 participant