dbt-labs/dbt-core · error · minijinja::Error (InvalidOperation)
Contract Error: {message}
Error message
Contract Error: {message} What it means
Fallback variant of the missing-contract-data_type error: the same 'Contracted models require data_type to be defined for each column' failure raised without node id/file path because `node_metadata_from_state(state)` returned None. The compilation still fails for the affected node.
Source
Thrown at crates/dbt-jinja-utils/src/functions/base.rs:1268
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);
let message = args.get::<String>("msg")?;
if let Some((node_id, file_path)) = node_metadata_from_state(state) {
Err(Error::new(
ErrorKind::InvalidOperation,
format!(
"FailFast Error for {} from {}: {}",
node_id,
file_path.display(),
message
),View on GitHub (pinned to 0267ce9170)
Solutions
- Add `data_type:` to all columns in the YAML contract block.
- Run via `dbt build`/`run` to get the located error variant pointing at the file.
- Ensure contract-validation macros run within a node context.
Example fix
# before
# Contract Error: Contracted models require data_type to be defined for each column...
# after (models/my_model.yml)
columns:
- name: id
data_type: bigint Defensive patterns
Strategy: validation
Validate before calling
import yaml
cfg = yaml.safe_load(open('models/my_model.yml'))
assert all('data_type' in c for c in cfg['models'][0]['columns']), 'missing data_type in contract' Prevention
- Validate the YAML contract with a schema linter in CI.
- Run dbt build (not parse) for contracted models to get located errors.
- Backfill data_type for all columns when first enabling contracts.
When it happens
Trigger: Missing data_type in a contracted model's YAML columns detected during Jinja evaluation when no node metadata is in state (parse/compile outside a model context, or dispatched macro without node info).
Common situations: Same as the located variant: contracted YAML missing `data_type`, evaluated outside a normal run path so the file location cannot be attached.
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 for {} from {}: {}
- 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/a1bac7cdbf5f0d0a.
Report an issue: GitHub.