{"record":{"id":"ea4068fbb2efe621","repo":"dbt-labs/dbt-core","slug":"compilation-error-for-node-id-from-file-path","errorCode":null,"errorMessage":"Compilation Error for {node_id} from {file_path}: {message}","messagePattern":"Compilation Error for (.+?) from (.+?): (.+?)","errorType":"exception","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/functions/base.rs","lineNumber":1135,"sourceCode":"                // handles the event level upgrade for dbt-facing outputs.\n                let warn_error_decision = self\n                    .warn_error_options\n                    .decision_for_error_code(warning.code)\n                    == WarnErrorDecision::UpgradeToError;\n                emit_warn_log_from_fs_error(*warning);\n\n                if warn_error_decision {\n                    return Err(Error::new(ErrorKind::ExitWithStatus, warn_string));\n                }\n\n                Ok(Value::UNDEFINED)\n            }\n            // (msg, node=None)\n            \"raise_compiler_error\" => {\n                let mut args = ArgParser::new(args, None);\n                let message = args.get::<String>(\"msg\")?;\n                if let Some((node_id, file_path)) = node_metadata_from_state(state) {\n                    Err(Error::new(\n                        ErrorKind::InvalidOperation,\n                        format!(\n                            \"Compilation Error for {} from {}: {}\",\n                            node_id,\n                            file_path.display(),\n                            message\n                        ),\n                    ))\n                } else {\n                    Err(Error::new(\n                        ErrorKind::InvalidOperation,\n                        format!(\"Compilation Error: {message}\"),\n                    ))\n                }\n            }\n            // (msg) String\n            \"raise_not_implemented\" => {\n                let mut args = ArgParser::new(args, None);","sourceCodeStart":1117,"sourceCodeEnd":1153,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/functions/base.rs#L1117-L1153","documentation":"`raise_compiler_error(msg)` (dbt's `exceptions.raise_compiler_error`) always aborts compilation. When node metadata is available in the Jinja state, the library wraps the user message with the node id and source file path to pinpoint which model/macro failed. The message content itself comes from the template author.","triggerScenarios":"A template calls `{{ exceptions.raise_compiler_error(\"...\") }}` during rendering of a known node — typically after a failed validation check inside a macro or model.","commonSituations":"Macro input validation (e.g. invalid materialization, missing required var via `var(..., raise)`, bad ref) deliberately failing the build; the real debugging task is reading the embedded message.","solutions":["Read the `{message}` part of the error to find the failed validation and fix the offending model/config","Guard the check with a default: `var('x', default_value)` instead of raising","Validate inputs before rendering, e.g. with `{% if %}` checks, and provide a corrected value"],"exampleFix":"// before\n{{ exceptions.raise_compiler_error(\"invalid config\") }}\n// after\n{% if not valid %}{{ exceptions.raise_compiler_error(\"invalid config: got \" ~ value) }}{% endif %}  // add context, or fix `value`","handlingStrategy":"try-catch","validationCode":"{% if not required_var_defined %}{{ log('pre-check failed before raise_compiler_error') }}{% endif %}","typeGuard":null,"tryCatchPattern":"// Parse the node id/file path from the message to locate the failing template\nlet re = regex::Regex::new(r\"Compilation Error for (\\S+) from ([^:]+): (.*)\")?;\nif let Some(c) = re.captures(&err.to_string()) { locate_and_fix(&c[1], &c[2], &c[3]) }","preventionTips":["Validate macro inputs early with {% if %} guards","Use var('name', default) to avoid missing-variable raises","Include the offending value in raise_compiler_error messages for faster triage"],"tags":["jinja","compiler-error","dbt"],"backgroundTag":"schema-validation-failed","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}