dbt-labs/dbt-core · error
pop(): key not found
Error message
pop(): key not found
What it means
Raised by OrderedDict.pop in the Jinja object emulation: the requested key is absent from the mapping and no `default` keyword was supplied, so there is nothing to return. Mirrors Python's KeyError from dict.pop without a default.
Solutions
- Pass a default: my_dict.pop('missing_key', default_value)
- Check key membership with 'key in my_dict' before popping
- Verify the key was actually set earlier in the template
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/dbt-agate/src/lib.rs:597 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/1dcb5c2de0864f91.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-agate/src/lib.rs:597
// --- mutating methods implemented via excluded ---
"pop" => {
// pop(key, default=())
// If key exists: create new inner with excluded index and return value.
// If missing: return default if provided, else error.
let iter = ArgsIter::new("OrderedDict.pop", &["key"], args);
let key = iter.next_arg::<&Value>()?;
let default = iter.next_kwarg::<Option<&Value>>("default")?;
iter.finish()?;
let mut inner = self.inner.lock().expect("lock poisoned");
if let Some((value, new)) = inner.pop(key) {
*inner = new;
Ok(value)
} else if let Some(default) = default {
Ok(default.clone())
} else {
Err(minijinja::Error::new(
ErrorKind::NonKey,
"pop(): key not found",
))
}
}
_ => Err(minijinja::Error::new(
ErrorKind::UnknownMethod,
format!("OrderedDict has no method named {name}"),
)),
}
}
}
/// A generic container for immutable data that can be accessed either by
/// numeric index or by key. This is similar to a Python `OrderedDict` except
/// that the keys are optional and iteration over it returns the values instead
/// of keys.View on GitHub (pinned to 0267ce9170)