dbt-labs/dbt-core · error · minijinja::Error (InvalidOperation)
Contract Error for {} from {}: {}
Error message
Contract Error for {} from {}: {} What it means
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.
Source
Thrown at crates/dbt-jinja-utils/src/functions/base.rs:1258
// Convert column_names to a vector of strings
let column_names_string = if column_names.is_undefined() {
"".to_string()
} else {
match column_names.try_iter() {
Ok(iter) => {
let strings: Vec<String> = iter.map(|v| v.to_string()).collect();
strings.join(", ")
}
Err(_) => "".to_string(),
}
};
let message = format!(
"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)."
);
if let Some((node_id, file_path)) = node_metadata_from_state(state) {
Err(Error::new(
ErrorKind::InvalidOperation,
format!(
"Contract Error for {} from {}: {}",
node_id,
file_path.display(),
message
),
))
} else {
Err(Error::new(
ErrorKind::InvalidOperation,
format!("Contract Error: {message}"),
))
}
}
// (msg, node=None)
"raise_fail_fast_error" => {
let mut args = ArgParser::new(args, None);View on GitHub (pinned to 0267ce9170)
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.
Example fix
# before
columns:
- name: id
- name: amount
# after
columns:
- name: id
data_type: bigint
- name: amount
data_type: numeric(18,2) Defensive patterns
Strategy: validation
Validate before calling
# Check every contracted column declares data_type before running dbt
import yaml
cfg = yaml.safe_load(open('models/my_model.yml'))
for col in cfg['models'][0]['columns']:
assert 'data_type' in col, f"column {col.get('name')} missing data_type" Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Contract Error: {message}
- Compilation Error for {} from {}: {}
- Column 'name' must be a string
- Expected a list of column definitions
- describe_dynamic_table is not supported by the {} adapter
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/58b35cb978221397.
Report an issue: GitHub.