Aias00 opened a new pull request, #3433:
URL: https://github.com/apache/dubbo-go/pull/3433
## Problem
`metadataSupplier` in `filter/otel/trace/attachment.go` has a type mismatch
between `Get` and `Set`:
- **`Set`** stores values as `string`: `s.metadata[key] = value`
- **`Get`** reads values as `[]string`: `s.metadata[key].([]string)`
When the OTel propagator calls `Inject` (which uses `Set`) followed by
`Extract` (which uses `Get`), the type assertion in `Get` fails and returns an
empty string. This breaks trace context propagation — `traceparent` and other
W3C trace headers are silently lost.
This is also a partial root cause of #3240 (traceparent being broken by
triple_invoker).
## Fix
### `Set` — store `[]string{value}` instead of `string`
This aligns with how triple's `generateAttachments` stores `http.Header`
values (as `[]string`), which is the data source on the Extract (server) side.
### `Get` — add defensive `string` type handling
In addition to `[]string`, `Get` now also handles plain `string` values.
This matches the pattern used by `RPCInvocation.GetAttachment` and provides
robustness against externally-set string values.
## Test Coverage
- Added `string value (defensive read)` test case — verifies Get reads
string type
- Added `non-string non-slice value` test case — verifies safe fallback
- Added `Test_metadataSupplier_SetGetRoundTrip` — the core bug scenario: Set
then Get must succeed, and stored type must be `[]string`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]