Skip to content

fix: return an error from GetClient when a backend has no live client#985

Merged
QuentinBisson merged 1 commit into
mainfrom
fix/aggregator-nil-client-panic
Jul 22, 2026
Merged

fix: return an error from GetClient when a backend has no live client#985
QuentinBisson merged 1 commit into
mainfrom
fix/aggregator-nil-client-panic

Conversation

@QuentinBisson

Copy link
Copy Markdown
Contributor

What

ServerRegistry.GetClient could return (nil, nil) when a backend was registered and reported connected (from the service registry's active state) but its Client pointer was momentarily absent during a reconnect. AggregatorServer.ReadResource and GetPrompt dereference 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 in ReadResource, which reset the agent's MCP tool session (ADK logged unhandled errors in a TaskGroup). The turn then hung silently and no answer reached Slack.

Change

GetClient now 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.

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
QuentinBisson marked this pull request as ready for review July 22, 2026 00:35
@QuentinBisson
QuentinBisson requested a review from a team as a code owner July 22, 2026 00:35
@QuentinBisson
QuentinBisson merged commit e580360 into main Jul 22, 2026
14 checks passed
@QuentinBisson
QuentinBisson deleted the fix/aggregator-nil-client-panic branch July 22, 2026 07:41
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.

2 participants