fix(triple): canonicalize context metadata headers#3428
Conversation
Signed-off-by: wuyangfan <yangfan.wu@succaiss.com>
96914fa to
901942d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3428 +/- ##
===========================================
+ Coverage 46.76% 53.55% +6.78%
===========================================
Files 295 493 +198
Lines 17172 38386 +21214
===========================================
+ Hits 8031 20557 +12526
- Misses 8287 16176 +7889
- Partials 854 1653 +799 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR canonicalizes Triple context metadata header keys when storing incoming/outgoing headers so that headers added via NewOutgoingContext and AppendToOutgoingContext unify under the same key and can be reliably accessed via standard http.Header methods (e.g., Get/Values). It also clarifies how unary clients can read response headers and trailers from the response wrapper.
Changes:
- Canonicalize context metadata keys using
http.CanonicalHeaderKeyin outgoing/incoming context helpers. - Make
IsReservedHeadercase-insensitive by lowercasing input before classification, with a focused unit test. - Add documentation/examples for response header/trailer access and outgoing context usage.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
protocol/triple/triple_protocol/triple.go |
Documents unary client usage for reading response headers/trailers via the response wrapper. |
protocol/triple/triple_protocol/protocol_grpc.go |
Lowercases inputs in IsReservedHeader to ensure reserved-header detection is case-insensitive. |
protocol/triple/triple_protocol/protocol_grpc_test.go |
Adds a test ensuring IsReservedHeader canonicalizes (lowercases) input. |
protocol/triple/triple_protocol/header.go |
Canonicalizes stored context header keys (incoming/outgoing) and aligns append behavior. |
protocol/triple/triple_protocol/header_test.go |
Adds an example verifying outgoing context + append results are accessible via Get/Values. |
protocol/invocation/rpcinvocation.go |
Lowercases extracted header keys before storing as invocation attachments for consistency. |
protocol/invocation/rpcinvocation_test.go |
Updates assertions to use http.Header.Values instead of direct map indexing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This looks like a reasonable compromise to me. Since these APIs expose Could we add a short comment around the |
|
Added short comments around the canonical context-header storage and lowercase exported-attachment boundary in 7fd64c2. Local validation passes: |
|



What
Canonicalize Triple context metadata header keys when storing incoming and outgoing headers. This keeps
NewOutgoingContextandAppendToOutgoingContextvalues under the same key and makes standardhttp.Header.Get/Valuesaccess work as documented.Also document how unary clients read response headers and trailers from the response wrapper.
Refs #2422
Validation
go test ./protocol/triple/triple_protocolgo test ./protocol/triplegit diff --check