@@ -357,12 +357,15 @@ Entrypoint constructors, all keyword-only:
357357 metrics_prefix=None, kind="grpc", essential=True)` . ` GrpcConfig` defaults:
358358 ` port=50051 ` , ` grace_period=30.0 ` , ` enable_reflection=False ` , ` enable_channelz=False ` ,
359359 ` health_service_names=() ` , ` health_refresh_interval=5.0 ` .
360+ ` GrpcConfig.context_metadata: dict[str, str] | None = None ` is ` {metadata_key: context_key} `
361+ for ` UnitScopeInterceptor ` : ` None ` reads ` x-request-id ` , ` x-user-id ` , ` x-tenant-id ` and
362+ ` x-trace-id ` , ` {} ` reads none and always mints the request id (rule 21).
360363 `GrpcConfig.from_settings(settings, * , health_service_names=(), health_refresh_interval=5.0,
361- reflection_service_names=None)` reads every other field off anything satisfying
362- grpc-server-kit's ` GrpcServerSettingsProtocol ` (` BaseGrpcServerSettings ` , ` GrpcServerConfig ` ) ,
363- the kit's defaults included (` [::] ` , ` grace_period=5.0 ` ); the three keywords are the fields no
364- settings object carries, and ` health_refresh_interval ` is deliberately not the kit's
365- ` health.cache_ttl ` (opposite meaning at ` 0 ` ). Interceptor chain, outermost first:
364+ reflection_service_names=None, context_metadata=None )` reads every other field off anything
365+ satisfying grpc-server-kit's ` GrpcServerSettingsProtocol ` (` BaseGrpcServerSettings ` ,
366+ ` GrpcServerConfig ` ), the kit's defaults included (` [::] ` , ` grace_period=5.0 ` ); the four keywords
367+ are the fields no settings object carries, and ` health_refresh_interval ` is deliberately not the
368+ kit's ` health.cache_ttl ` (opposite meaning at ` 0 ` ). Interceptor chain, outermost first:
366369 ` UnitScopeInterceptor ` , ` UnhandledErrorInterceptor ` , metrics, yours,
367370 ` ServiceErrorInterceptor ` .
368371* `SchedulerEntrypoint(jobs, enable_metrics=False, metrics_prefix=None,
@@ -486,14 +489,16 @@ Each `*Plugin` takes exactly the same arguments as its entrypoint and exposes `.
486489 ` min(host drain_grace_seconds, its own cap) ` : ` GrpcConfig.grace_period ` for gRPC,
487490 ` graceful_timeout ` for FastAPI and Litestar (` 0 ` there sets no cap). Both caps default to
488491 30.0, the default grace; raising ` drain_grace_seconds ` above that needs the cap raised too.
489- 21 . ** The FastAPI context headers are client input.** By default ` x-user-id ` , ` x-tenant-id `
490- and ` x-trace-id ` are bound from any request into the logs, the Sentry user and tags, and
491- ` propagation_metadata() ` , which forwards them downstream. ` is_safe_context_id ` checks the
492- characters, not the sender. Behind an edge that strips or sets them this is fine; on a port
493- untrusted clients reach, pass
492+ 21 . ** The FastAPI context headers and the gRPC context metadata are client input.** By default
493+ ` x-user-id ` , ` x-tenant-id ` and ` x-trace-id ` are bound from any request or RPC into the logs,
494+ the Sentry user and tags (HTTP), OTel baggage, and ` propagation_metadata() ` , which forwards
495+ them downstream. ` is_safe_context_id ` checks the characters, not the sender. Behind an edge
496+ that strips or sets them this is fine; on a port untrusted clients reach, pass
494497 ` MiddlewareConfig(context_headers={"x-request-id": "request_id"}) ` , or set
495- ` SERVER__MIDDLEWARES__CONTEXT_HEADERS='{"x-request-id":"request_id"}' ` . The gRPC
496- interceptor reads the same metadata keys and has no such setting.
498+ ` SERVER__MIDDLEWARES__CONTEXT_HEADERS='{"x-request-id":"request_id"}' ` . Over gRPC pass
499+ ` GrpcConfig(context_metadata={"x-request-id": "request_id"}) ` ; the kit's settings model has
500+ no such field, so an environment variable needs a settings field of your own passed to
501+ ` GrpcConfig.from_settings(..., context_metadata=...) ` .
497502
498503## Common mistakes
499504
0 commit comments