{"record":{"id":"bd36fa775bca307c","repo":"ethereum/go-ethereum","slug":"nil-textmappropagator-configured","errorCode":null,"errorMessage":"nil TextMapPropagator configured","messagePattern":"nil TextMapPropagator configured","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rpc/client_opt.go","lineNumber":109,"sourceCode":"func WithHeaders(headers http.Header) ClientOption {\n\treturn optionFunc(func(cfg *clientConfig) {\n\t\tcfg.initHeaders()\n\t\tfor k, vs := range headers {\n\t\t\tcfg.httpHeaders[k] = vs\n\t\t}\n\t})\n}\n\n// WithTextMapPropagator configures OpenTelemetry trace propagation.\n// Note, by default, trace context is NOT propagated by rpc.Client.\n// To enable propagation via the `traceparent` header, you must explicitly\n// enable it by setting a propagator, e.g.\n//\n//\tprop := propagation.TraceContext{}\n//\tc, err := rpc.DialOptions(ctx, \"http://\", rpc.WithTextMapPropagator(prop))\nfunc WithTextMapPropagator(tmp propagation.TextMapPropagator) ClientOption {\n\tif tmp == nil {\n\t\tpanic(\"nil TextMapPropagator configured\")\n\t}\n\treturn optionFunc(func(cfg *clientConfig) {\n\t\tcfg.tmprop = tmp\n\t})\n}\n\n// WithHTTPClient configures the http.Client used by the RPC client.\nfunc WithHTTPClient(c *http.Client) ClientOption {\n\treturn optionFunc(func(cfg *clientConfig) {\n\t\tcfg.httpClient = c\n\t})\n}\n\n// WithHTTPAuth configures HTTP request authentication. The given provider will be called\n// whenever a request is made. Note that only one authentication provider can be active at\n// any time.\nfunc WithHTTPAuth(a HTTPAuth) ClientOption {\n\tif a == nil {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/ethereum/go-ethereum/blob/6bb0588ad8e7f922e4ad5580f51265a4097af08f/rpc/client_opt.go#L91-L127","documentation":"WithTextMapPropagator panics when passed a nil propagator. This client option enables OpenTelemetry trace-context propagation (the traceparent header); because the client does not propagate by default, the option stores the propagator unconditionally, so a nil value is rejected as a configuration programming error at DialOptions time.","triggerScenarios":"Calling rpc.DialOptions(ctx, url, rpc.WithTextMapPropagator(nil)) or passing a propagator variable declared as var prop propagation.TextMapPropagator and never assigned.","commonSituations":"Making tracing optional in application config and forwarding a nil when tracing is disabled; passing an uninitialized struct field from a config struct; refactoring from a global otel.GetTextMapPropagator() that returned nil before OTel SDK initialization.","solutions":["Pass a concrete propagator, e.g. rpc.WithTextMapPropagator(propagation.TraceContext{}).","If tracing is optional, guard the call: only append the option when the propagator is non-nil.","Ensure the OpenTelemetry SDK is initialized before reading a global propagator."],"exampleFix":"// before\nvar prop propagation.TextMapPropagator // nil when tracing disabled\nc, err := rpc.DialOptions(ctx, url, rpc.WithTextMapPropagator(prop))\n\n// after\nvar opts []rpc.ClientOption\nif prop != nil {\n    opts = append(opts, rpc.WithTextMapPropagator(prop))\n}\nc, err := rpc.DialOptions(ctx, url, opts...)","handlingStrategy":"validation","validationCode":"var opts []rpc.ClientOption\nif prop != nil { // skip option entirely when tracing disabled\n    opts = append(opts, rpc.WithTextMapPropagator(prop))\n}\nc, err := rpc.DialOptions(ctx, url, opts...)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only append WithTextMapPropagator when the propagator is non-nil.","Initialize the OTel SDK (which installs a global propagator) before building clients.","Unit-test the option-building function with the 'tracing disabled' config path."],"tags":["rpc","opentelemetry","tracing","nil-check","config","panic","go"],"backgroundTag":null,"analyzedSha":"6bb0588ad8e7f922e4ad5580f51265a4097af08f","analyzedAt":"2026-08-15T10:06:53.996Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}