Skip to content

fix(client): name the server address in connection errors - #2535

Merged
tkircsi merged 1 commit into
agntcy:mainfrom
uveshm003:fix/name-server-in-connection-errors
Nov 23, 2026
Merged

tkircsi merged 1 commit into
agntcy:mainfrom
uveshm003:fix/name-server-in-connection-errors

Conversation

@uveshm003

Copy link
Copy Markdown
Contributor

Fixes #2532

The client wraps errors in about 115 places, so instead of editing each one, client.New adds a unary and a stream interceptor. They append (server <address>) to Unavailable errors when a call or stream is opened, and when an open stream sends or receives. The error stays a gRPC status with the same code and details, so callers that check status.Code see no change. Other codes, io.EOF and nil pass through unchanged.

The issue's case, reproduced with an HTTP/1.1 server on the dialled port:

failed to create list workload stream: rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: http2: failed reading the frame payload: http2: frame too large, note that the frame header looked like an HTTP/1.1 header" (server 127.0.0.1:58564)

A plain dial failure, which already names the address, now names it twice. I kept that rather than parse the message.

Testing

  • go test ./... in client. The new TestConnectionErrorsNameTheServer (a stream and a unary call against an HTTP/1.1 server) fails on main.
  • go test ./... in cli. It builds against the published client, so it doesn't exercise this change.
  • golangci-lint v2.14.0 with the repo config: 0 issues.

A connection that reaches a listener that is not a gRPC server fails
with "error reading server preface: ... looked like an HTTP/1.1 header"
and nothing says which address was dialled. dirctl takes that address
from a context, an environment variable or a flag, so it is easy to
look for the problem in the wrong place.

The client now adds two interceptors that append "(server <address>)"
to Unavailable errors: when a unary call or stream is opened, and when
an open stream sends or receives. The error stays a gRPC status with the
same code and details, so callers that check the code see no change.
Other errors pass through untouched.

Fixes agntcy#2532

Signed-off-by: Uvesh Menpur <[email protected]>
@uveshm003
uveshm003 requested a review from a team as a code owner November 23, 2026 13:24
@github-actions github-actions Bot added the size/S Denotes a PR that changes 50-199 lines label Nov 23, 2026

@tkircsi tkircsi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @uveshm003 ! Nice fix, thanks for the thorough testing notes. Exactly what #2532 asked for. The interceptor approach is a much nicer call than touching ~115 wrap sites, and the error-handling details are right: nil and io.EOF pass through untouched (so the errors.Is(err, io.EOF) stream-termination checks in client/ keep working), st.Proto() clones so status details survive, the code stays Unavailable, and the stream wrapper is stateless so concurrent SendMsg/RecvMsg on bidi streams is safe.

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tkircsi
tkircsi added this pull request to the merge queue Nov 23, 2026
Merged via the queue into agntcy:main with commit 5e5a63a Nov 23, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 50-199 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Client connection errors never name the address that was dialled

2 participants