fix: return an error from GetClient when a backend has no live client#985
Merged
Conversation
A backend that reported connected (from the service registry's active state) while its client pointer was momentarily absent during a reconnect made GetClient return (nil, nil). ReadResource and GetPrompt dereference the client directly, so this panicked the request goroutine and aborted the MCP connection mid-stream. GetClient now rejects a nil client.
QuentinBisson
marked this pull request as ready for review
July 22, 2026 00:35
paurosello
approved these changes
Jul 22, 2026
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.
What
ServerRegistry.GetClientcould return(nil, nil)when a backend was registered and reported connected (from the service registry's active state) but itsClientpointer was momentarily absent during a reconnect.AggregatorServer.ReadResourceandGetPromptdereference the returned client directly, so this panicked the request goroutine (recovered per-connection by mcp-go) and aborted the MCP HTTP connection mid-request.Why
Observed on gazelle 2026-07-21: an sre-agent turn called
get_resource(roadmap://schema); muster panicked with a nil-pointer dereference inReadResource, which reset the agent's MCP tool session (ADK loggedunhandled errors in a TaskGroup). The turn then hung silently and no answer reached Slack.Change
GetClientnow returns an error when the resolved server has a nil client, so the tool call fails cleanly instead of crashing the connection. This covers every caller (ReadResource,GetPrompt). Adds a unit test; also clears two modernization hints (maps.Copy,range-over-int) on the touched files.