CodeSampleX

Sample

google.golang.org/grpc v1.83.0: Preserve caller-supplied outgoing gRPC metadata when a unary client interceptor adds its own metadata

Verified sample for golang google.golang.org/grpc v1.83.0: Preserve caller-supplied outgoing gRPC metadata when a unary client interceptor adds its own…

sha256:a8acd8ef9a84180020f012467fae967f3de130dff4d432708ac5bf0a6df64717

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment go 1.26 linux x64 go 1.26 go go

Verification-run environments

Environment Contract Stages Run
go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-17
go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-18

Case

HOW
Goal
Preserve caller-supplied outgoing gRPC metadata when a unary client interceptor adds its own metadata
Packages
Symbols
  • google.golang.org/grpc.NewServer
  • google.golang.org/grpc.Server.RegisterService
  • google.golang.org/grpc.NewClient
  • google.golang.org/grpc.WithContextDialer
  • google.golang.org/grpc.WithTransportCredentials
  • google.golang.org/grpc.WithUnaryInterceptor
  • google.golang.org/grpc.ClientConn.Invoke
  • google.golang.org/grpc/test/bufconn.Listen
  • google.golang.org/grpc/metadata.NewOutgoingContext
  • google.golang.org/grpc/metadata.AppendToOutgoingContext
  • google.golang.org/grpc/metadata.FromIncomingContext
  • google.golang.org/grpc/status.Code
Environment
go 1.26
Created
2026-08-17T01:31:28Z

Contract

  1. A grpc.NewClient call reaches a manually registered unary service through bufconn, a context dialer, and insecure transport credentials without opening a TCP listener.
  2. When a unary client interceptor uses metadata.NewOutgoingContext, the server receives the interceptor field but not the caller's existing x-caller field, and its status error arrives at the client as codes.Unauthenticated.
  3. When the interceptor uses metadata.AppendToOutgoingContext instead, metadata.FromIncomingContext sees both the caller and interceptor fields and the unary call succeeds.

Files

  • NOTES.md
  • csx.json
  • go.mod
  • go.sum
  • metadata_interceptor_test.go

Download the source artifact (tar.gz)

Origin Seeder

csx-seed