{"record":{"id":"9e304283675b5a68","repo":"dbt-labs/dbt-core","slug":"name-span-is-required","errorCode":null,"errorMessage":"name_span is required","messagePattern":"name_span is required","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-schemas/src/schemas/macros.rs","lineNumber":123,"sourceCode":"    project_root: &Path,\n) -> BTreeMap<String, Vec<MacroUnit>> {\n    let mut macros = BTreeMap::new();\n    for (_, inner_macro) in nodes.iter() {\n        let display_path = inner_macro\n            .get_node_path(NodePathKind::Definition, project_root, project_root)\n            .into_owned();\n        macros\n            .entry(inner_macro.package_name.clone())\n            .or_insert(vec![])\n            .push(MacroUnit {\n                info: MacroInfo {\n                    name: inner_macro.name.clone(),\n                    path: display_path,\n                    span: inner_macro.span.expect(\"span is required\"),\n                    funcsign: inner_macro.funcsign.clone(),\n                    args: inner_macro.args.clone(),\n                    unique_id: inner_macro.unique_id.clone(),\n                    name_span: inner_macro.macro_name_span.expect(\"name_span is required\"),\n                },\n                sql: inner_macro.macro_sql.clone(),\n            });\n    }\n    macros\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn test_macro_config_default_serializes_docs_with_nulls() {\n        // serialize_docs_with_nulls forces both fields to be present, including\n        // node_color (normally Option-skipped) as an explicit null.\n        let config = MacroConfig::default();\n        let json = serde_json::to_value(&config).expect(\"serializes\");\n        let docs = json.get(\"docs\").expect(\"docs key present\");","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-schemas/src/schemas/macros.rs#L105-L141","documentation":"Sibling of the span assertion: building `MacroInfo` panics with `inner_macro.macro_name_span.expect(\"name_span is required\")` when the macro's name span (the byte range of the macro's name in its source file) is `None`. The name span is required for macro resolution diagnostics and docs; the library treats its absence as a broken parse result.","triggerScenarios":"Aggregating macros into the manifest with an `InnerMacro` whose `macro_name_span: Option<Span>` is `None` — same causes as the span assertion: partially-deserialized macros, artifact version mismatch, or programmatic construction that skipped name-span extraction.","commonSituations":"Loading macros from a cached/partial parse artifact that omitted `macro_name_span`; custom code paths or tests that construct macros without recording the name span.","solutions":["Parse macros through the standard parser path so `macro_name_span` is populated from the source text","Regenerate serialized macro artifacts with the matching dbt version","Set `macro_name_span` explicitly when constructing `InnerMacro` in tooling/tests"],"exampleFix":"// before\nname_span: inner_macro.macro_name_span.expect(\"name_span is required\"),\n// after\nname_span: inner_macro.macro_name_span.unwrap_or_default(),","handlingStrategy":"validation","validationCode":"// before manifest aggregation\nif inner_macro.macro_name_span.is_none() {\n    return Err(/* error: macro {} missing name_span; re-parse */);\n}","typeGuard":"fn has_name_span(m: &InnerMacro) -> bool { m.macro_name_span.is_some() }","tryCatchPattern":"let result = std::panic::catch_unwind(|| build_macros(resolver_state));","preventionTips":["Never build InnerMacro by hand in tests without setting both span and macro_name_span","Pin artifact schema versions when caching parsed macros","Fail at parse time (not aggregation time) if a name span cannot be extracted"],"tags":["macros","span","panic","manifest"],"backgroundTag":"internal-invariant-violation","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"}