{"record":{"id":"7e98af9496050230","repo":"dbt-labs/dbt-core","slug":"otel-trace-id-takes-no-arguments","errorCode":null,"errorMessage":"otel_trace_id() takes no arguments","messagePattern":"otel_trace_id\\(\\) takes no arguments","errorType":"validation","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/functions/base.rs","lineNumber":360,"sourceCode":"        Some(&tracker),\n        state,\n        args,\n    )\n}\n\n/// Builds the `otel_trace_id()` Jinja function. Must be a callable, not a\n/// plain global, to match how dbt Core v1 exposes it. Captures the trace id\n/// once (unlike `otel_span_id()`, which re-reads live since span id does\n/// change within an invocation).\npub fn otel_trace_id_fn() -> impl Fn(&[Value], Kwargs) -> Result<Value, Error> {\n    let trace_id = dbt_common::tracing::span_info::read_current_span_start_info(|info| {\n        format!(\"{:032x}\", info.trace_id)\n    });\n    let trace_id = Value::from(trace_id.unwrap_or_else(|| \"0\".repeat(32)));\n\n    move |args: &[Value], _kwargs: Kwargs| -> Result<Value, Error> {\n        if !args.is_empty() {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                \"otel_trace_id() takes no arguments\",\n            ));\n        }\n        Ok(trace_id.clone())\n    }\n}\n\n/// Returns the current span's OTEL id (16-char hex).\n///\n/// Real code always runs inside a tracing dispatcher, so a missing span is a\n/// bug, not a supported state: debug builds assert, release builds fall back\n/// to the OTEL-standard invalid span id (all zeros).\npub fn otel_span_id(_state: &State, args: &[Value]) -> Result<Value, Error> {\n    let iter = ArgsIter::nullary(\"otel_span_id\", args);\n    iter.finish()?;\n\n    let span_id = dbt_common::tracing::span_info::read_current_span_start_info(|info| {","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/functions/base.rs#L342-L378","documentation":"The otel_trace_id() Jinja function returns the current OpenTelemetry trace id as a 32-character hex string (or 32 zeros when unavailable). It takes no arguments; passing any positional argument raises this InvalidOperation error.","triggerScenarios":"Calling {{ otel_trace_id('x') }} or {{ otel_trace_id(some_var) }} with one or more positional arguments.","commonSituations":"Copy-paste from other trace/correlation-id helpers that accept arguments; confusion with functions like log() that take parameters.","solutions":["Call it with empty parentheses: {{ otel_trace_id() }}.","Remove any arguments, including optional-looking ones.","If you need to embed the trace id in a message, concatenate the no-arg call result."],"exampleFix":"// before\n{{ otel_trace_id(request_id) }}\n// after\n{{ otel_trace_id() }}","handlingStrategy":"validation","validationCode":"{% if arguments | length > 0 %}{% do exceptions.raise_compiler_error('otel_trace_id takes no args') %}{% endif %}","typeGuard":null,"tryCatchPattern":"{% set trace_id = otel_trace_id() %}","preventionTips":["Always call otel_trace_id() with empty parentheses.","Do not confuse it with functions that accept formatting arguments."],"tags":["jinja","otel","tracing","arguments"],"backgroundTag":"invalid-argument","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}