You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gRPC: choose which metadata keys bind the request context; client-sent x-user-id/x-tenant-id are trusted and propagated #112
The gRPC adapter has the same trust model as the HTTP one in #110. UnitScopeInterceptor builds the unit context from get_correlation_ids (adapters/grpc/metadata.py), and that function always reads x-request-id, x-user-id, x-tenant-id and x-trace-id from the incoming metadata. The mapping is a module constant, _CORRELATION_METADATA_KEYS, and neither the interceptor nor GrpcConfig can change it.
A client that reaches the gRPC port therefore sets user_id and tenant_id. Those values end up in every log line and in the propagated metadata of outbound calls, the same way they do over HTTP.
Proposal
Mirror #110: a context_metadata: dict[str, str] | None field on GrpcConfig, also a keyword of GrpcConfig.from_settings (the settings model belongs to grpc-server-kit), passed to UnitScopeInterceptor. None keeps today's four keys and {} reads none. Document the trust model in docs/adapters/grpc.md next to the table of metadata keys.
Acceptance
With context_metadata={"x-request-id": "request_id"}, a call that carries x-user-id metadata binds no user_id, and propagation_metadata() inside the handler returns only x-request-id.
PR is up: #118, stacked on #115. Same semantics as the HTTP side: GrpcConfig.context_metadata and a from_settings(..., context_metadata=...) keyword. None keeps the four keys and {} reads none. grpc-server-kit's settings model has no such field, so the docs show how to add one to your own subclass and get GRPC__CONTEXT_METADATA.
Activity
AlexeyShalaev commentedon Nov 13, 2026
PR is up: #118, stacked on #115. Same semantics as the HTTP side:
GrpcConfig.context_metadataand afrom_settings(..., context_metadata=...)keyword.Nonekeeps the four keys and{}reads none. grpc-server-kit's settings model has no such field, so the docs show how to add one to your own subclass and getGRPC__CONTEXT_METADATA.