Aias00 opened a new pull request, #3514: URL: https://github.com/apache/dubbo-go/pull/3514
## What Provider response attachments set via `res.Attachments()` were silently dropped and never reached the client. ## Why `appendTripleOutgoingAttachments` called `tri.AppendToOutgoingContext(ctx, ...)` and **discarded the returned context**. `context.Context` is immutable; the unary handler closure cannot propagate a reassigned `ctx` back to the framework, so `handler.go`'s `ExtractFromOutgoingContext(ctx)` always read the original server context — which is never initialized with an outgoing context (`handler.go:112` only sets `handlerOutgoingKey`, not `extraDataKey`) — and returned `nil`. The `mergeHeaders(conn.ResponseTrailer(), nil)` therefore wrote nothing. This was latent since #2928 switched the server path from `triResp.Trailer().Set` to `AppendToOutgoingContext`. The existing unit test masked it because it pre-initialized the context with `tri.NewOutgoingContext(...)`, so the `!ok` branch (which creates a throwaway new context) never ran. ## Fix Write attachments directly onto the `*tri.Response`'s `Trailer()`/`Header()`. The triple handler already merges `response.Header()` and `response.Trailer()` into the connection's outgoing headers/trailers (`handler.go:126-127`), so this is the path that actually reaches the client. - `string` → `Trailer().Set` - `[]string` → `Trailer().Add` (preserves all values; pre-#2928 only kept `val[0]`) - non-string → `Header().Set` (formatted) ## Tests Updated `TestAppendTripleOutgoingAttachments` to assert trailer/header population (instead of the pre-initialized context that masked the bug). Added nil-response and empty-attachments no-op cases. Fixes #3511 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
