{"record":{"id":"58b35cb978221397","repo":"dbt-labs/dbt-core","slug":"contract-error-for-from","errorCode":null,"errorMessage":"Contract Error for {} from {}: {}","messagePattern":"Contract Error for (.+?) from (.+?): (.+?)","errorType":"exception","errorClass":"minijinja::Error (InvalidOperation)","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/functions/base.rs","lineNumber":1258,"sourceCode":"\n                // Convert column_names to a vector of strings\n                let column_names_string = if column_names.is_undefined() {\n                    \"\".to_string()\n                } else {\n                    match column_names.try_iter() {\n                        Ok(iter) => {\n                            let strings: Vec<String> = iter.map(|v| v.to_string()).collect();\n                            strings.join(\", \")\n                        }\n                        Err(_) => \"\".to_string(),\n                    }\n                };\n\n                let message = format!(\n                    \"Contracted models require data_type to be defined for each column.  Please ensure that the column name and data_type are defined within the YAML configuration for the {column_names_string} column(s).\"\n                );\n                if let Some((node_id, file_path)) = node_metadata_from_state(state) {\n                    Err(Error::new(\n                        ErrorKind::InvalidOperation,\n                        format!(\n                            \"Contract 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!(\"Contract Error: {message}\"),\n                    ))\n                }\n            }\n            // (msg, node=None)\n            \"raise_fail_fast_error\" => {\n                let mut args = ArgParser::new(args, None);","sourceCodeStart":1240,"sourceCodeEnd":1276,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/functions/base.rs#L1240-L1276","documentation":"Contracted models require every column listed in YAML to declare a `data_type`. When the contract validation helper finds column(s) missing a data_type, it raises this error, prefixed with the node id and file path when node metadata is available in the Jinja state.","triggerScenarios":"`get_contract_mismatches`/contract-checking path in `call_method` encounters a YAML `columns:` entry for a contract-enforced model whose `data_type` (and/or name) is absent, e.g. from the `(column_names)` validation branch.","commonSituations":"Enabling `contract.enforced: true` on a model whose YAML columns were defined without `data_type:`; hand-written or generated YAML omitted data_type; copying a non-contracted model's YAML to a contracted one.","solutions":["Add a `data_type:` to every column in the model's YAML `columns:` block.","Verify the model has `config: contract: enforced: true` and the YAML matches the warehouse types.","Regenerate the YAML (e.g. `dbt docs generate` / codegen) and fill in data types."],"exampleFix":"# before\ncolumns:\n  - name: id\n  - name: amount\n\n# after\ncolumns:\n  - name: id\n    data_type: bigint\n  - name: amount\n    data_type: numeric(18,2)","handlingStrategy":"validation","validationCode":"# Check every contracted column declares data_type before running dbt\nimport yaml\ncfg = yaml.safe_load(open('models/my_model.yml'))\nfor col in cfg['models'][0]['columns']:\n    assert 'data_type' in col, f\"column {col.get('name')} missing data_type\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add data_type whenever adding a column entry to a contracted model's YAML.","Use codegen/CI lint rules that require data_type on columns of contract-enforced models.","Enable contracts only after YAML is complete for the model."],"tags":["dbt","jinja","contract","yaml","schema-validation"],"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-14T16:17:12.679Z"}