{"record":{"id":"5c88ccede0e946b3","repo":"denoland/deno","slug":"failed-to-inject-with-propagator-constructor-nam","errorCode":null,"errorMessage":"Failed to inject with ${propagator.constructor.name}.","messagePattern":"Failed to inject with (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ext/telemetry/telemetry.ts","lineNumber":1829,"sourceCode":"        ArrayPrototypeReduce(\n          ArrayPrototypeMap(\n            this.#propagators,\n            (p) => p.fields(),\n          ),\n          (x, y) => ArrayPrototypeConcat(x, y),\n          [],\n        ),\n      ),\n    );\n  }\n\n  inject(context: Context, carrier: unknown, setter: TextMapSetter): void {\n    for (const propagator of new SafeArrayIterator(this.#propagators)) {\n      try {\n        propagator.inject(context, carrier, setter);\n      } catch (err) {\n        // deno-lint-ignore no-console\n        console.warn(\n          `Failed to inject with ${propagator.constructor.name}.`,\n          err,\n        );\n      }\n    }\n  }\n\n  extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {\n    return ArrayPrototypeReduce(this.#propagators, (ctx, propagator) => {\n      try {\n        return propagator.extract(ctx, carrier, getter);\n      } catch (err) {\n        // deno-lint-ignore no-console\n        console.warn(\n          `Failed to extract with ${propagator.constructor.name}.`,\n          err,\n        );\n      }","sourceCodeStart":1811,"sourceCodeEnd":1847,"githubUrl":"https://github.com/denoland/deno/blob/a961cdec3b1948844414ebeecc697dcad76df2d1/ext/telemetry/telemetry.ts#L1811-L1847","documentation":"Deno's vendored OpenTelemetry SDK (ext/telemetry/telemetry.ts) wraps CompositePropagator.inject: each registered propagator runs inside try/catch, and a throw is reduced to this warning carrying the propagator's constructor name and the error, then the loop continues with the remaining propagators. Trace/context headers may be partially or fully missing from outgoing carriers afterwards.","triggerScenarios":"Calling the inject path (directly or via automatic outbound instrumentation) while the active Context holds an invalid SpanContext (malformed traceId/spanId, usually from hand-built contexts or custom samplers), or a registered custom propagator throwing against the supplied carrier/setter. W3CTraceContextPropagator and B3 variants are the usual constructor names in the message.","commonSituations":"Hand-crafted trace ids that are the wrong length or contain non-hex characters; custom propagators registered via propagation.setGlobalPropagator that assume a header-map carrier but receive something else; context lost/reset mid-request leaving inconsistent state; SDK version drift after Deno upgrades.","solutions":["Inspect the err logged right after the message; invalid trace/span ids are the most common cause","Build contexts only through the otel API (trace.setSpan, valid SpanContext objects) instead of assembling ids manually","Upgrade Deno, since fixes to the vendored propagators land in runtime releases","If a custom propagator is registered, unit-test its inject() against your exact carrier and setter types before registration"],"exampleFix":"// before: hand-built context with a bad trace id -> propagator.inject throws, warning logged\nconst ctx = trace.setSpan(ROOT_CONTEXT, { spanContext: { traceId: \"xyz\", spanId: \"1\", ... } });\npropagator.inject(ctx, outgoingHeaders, defaultSetter);\n\n// after: use the API to build valid contexts\nconst span = tracer.startSpan(\"out\");\npropagator.inject(trace.setSpan(ROOT_CONTEXT, span), outgoingHeaders, defaultSetter);\nspan.end();","handlingStrategy":"try-catch","validationCode":"// verify the active context is injectable before propagating\nconst span = trace.getSpan(activeContext);\nconst sc = span?.spanContext();\nconst safeContext = sc && /^[\\da-f]{32}$/.test(sc.traceId) && /^[\\da-f]{16}$/.test(sc.spanId)\n  ? activeContext\n  : ROOT_CONTEXT;\npropagator.inject(safeContext, carrier, setter);","typeGuard":"function hasValidTrace(ctx: Context): boolean {\n  const sc = trace.getSpan(ctx)?.spanContext();\n  return !!sc && /^[\\da-f]{32}$/.test(sc.traceId) && /^[\\da-f]{16}$/.test(sc.spanId) && sc.traceFlags !== undefined;\n}","tryCatchPattern":"// never let a broken propagator take down the request path\ntry {\n  propagator.inject(context, carrier, setter);\n} catch (err) {\n  diag.warn?.(\"trace inject failed; continuing without propagation\", err);\n}","preventionTips":["Create contexts only through the otel API (trace.setSpan, propagation.setGlobalPropagator)","Never hand-assemble trace ids; use samplers and the tracer API","Unit-test custom propagators' inject against your real carrier/setter types before registering them"],"tags":["telemetry","opentelemetry","context-propagation","tracing"],"backgroundTag":"context-propagation-failed","analyzedSha":"a961cdec3b1948844414ebeecc697dcad76df2d1","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}