AlexStocks commented on code in PR #3315:
URL: https://github.com/apache/dubbo-go/pull/3315#discussion_r3161590636
##########
protocol/triple/triple_invoker.go:
##########
@@ -161,6 +162,11 @@ func mergeAttachmentToOutgoing(ctx context.Context, inv
base.Invocation) (contex
if timeout, ok := inv.GetAttachment(constant.TimeoutKey); ok {
ctx = context.WithValue(ctx, tri.TimeoutKey{}, timeout)
}
+ // Reset outgoing headers with a fresh empty header before appending.
+ // Without this, AppendToOutgoingContext mutates a shared http.Header
pointer
+ // from the parent context, causing traceparent accumulation when the
same
+ // parent ctx is reused across serial RPCs (e.g. Service A → B then A →
C).
+ ctx = tri.NewOutgoingContext(ctx, http.Header{})
Review Comment:
[P1] 这里用 `tri.NewOutgoingContext(ctx, http.Header{})` 直接重建了整个 outgoing
header。`protocol/triple/triple_protocol/header.go` 的实现会替换掉 ctx 里已有的
header,因此调用方原本通过 `tri.NewOutgoingContext`/`AppendToOutgoingContext` 放进去的鉴权头、自定义
metadata 等都会被静默丢掉,只剩 invocation attachments。这个补丁修掉了 traceparent 串写,但同时引入了“其他
header 全丢”的回归。建议先克隆已有 outgoing header,再只覆盖/去重 trace 相关 key。
--
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]