fix(otel): fix metadataSupplier Get/Set type mismatch breaking trace propagation#3433
fix(otel): fix metadataSupplier Get/Set type mismatch breaking trace propagation#3433Aias00 wants to merge 4 commits into
Conversation
…propagation
Set stored values as string but Get expected []string, causing type
assertion failure when OTel propagator Inject followed by Extract.
Trace context (traceparent etc.) was lost during propagation.
- Set: store []string{value} instead of string, consistent with
triple's generateAttachments which stores http.Header values as
[]string
- Get: add defensive string type handling alongside []string, matching
RPCInvocation.GetAttachment's pattern for robustness
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes metadataSupplier so Set() stores values in the same shape that Get() expects (and that upstream attachment generation produces), preventing trace context values (e.g., traceparent) from being lost during round-trip usage.
Changes:
- Update
metadataSupplier.Getto handle both[]stringandstringvalues safely. - Update
metadataSupplier.Setto store values as[]string{value}. - Expand unit tests to cover additional metadata value types and a Set/Get round-trip.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| filter/otel/trace/attachment.go | Aligns Set() storage format with Get() expectations; adds defensive reads for string values. |
| filter/otel/trace/attachment_test.go | Adds coverage for slice/string/non-string values and validates Set/Get round-trip behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3433 +/- ##
===========================================
+ Coverage 46.76% 53.57% +6.80%
===========================================
Files 295 493 +198
Lines 17172 38392 +21220
===========================================
+ Hits 8031 20569 +12538
- Misses 8287 16171 +7884
- Partials 854 1652 +798 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|



Problem
metadataSupplierinfilter/otel/trace/attachment.gohas a type mismatch betweenGetandSet:Setstores values asstring:s.metadata[key] = valueGetreads values as[]string:s.metadata[key].([]string)When the OTel propagator calls
Inject(which usesSet) followed byExtract(which usesGet), the type assertion inGetfails and returns an empty string. This breaks trace context propagation —traceparentand 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 ofstringThis aligns with how triple's
generateAttachmentsstoreshttp.Headervalues (as[]string), which is the data source on the Extract (server) side.Get— add defensivestringtype handlingIn addition to
[]string,Getnow also handles plainstringvalues. This matches the pattern used byRPCInvocation.GetAttachmentand provides robustness against externally-set string values.Test Coverage
string value (defensive read)test case — verifies Get reads string typenon-string non-slice valuetest case — verifies safe fallbackTest_metadataSupplier_SetGetRoundTrip— the core bug scenario: Set then Get must succeed, and stored type must be[]string🤖 Generated with Claude Code