dbt-labs/dbt-core · error · minijinja::Error
to_dict() takes no arguments
Error message
to_dict() takes no arguments
What it means
VarProvider exposes a minijinja method table where 'to_dict' is hard-coded to accept zero arguments. The handler explicitly checks `!args.is_empty()` and returns a minijinja::Error with ErrorKind::TooManyArguments when any argument is supplied. It exists so templates can convert the wrapped value (`self.0.clone()`) via `to_dict()` with no parameters.
Solutions
- Call `to_dict()` with no arguments at all in the template
- If you need filtering, call `to_dict()` first and filter the resulting dict in the template (e.g. `{% for k, v in to_dict() %}`)
- If you genuinely need arguments, modify the match arm in state.rs to accept and use args instead of rejecting them
Example fix
// before (template)
{% set vars = var_provider.to_dict('schema') %}
// after
{% set vars = var_provider.to_dict() %}
{% set schema_vars = vars.get('schema', {}) %} Defensive patterns
Strategy: validation
Validate before calling
// In template/macros, guard before calling:
// {% if caller_args | length > 0 %}{% raise 'to_dict() takes no arguments' %}{% endif %}
// In Rust, before invoking the method dispatch:
if !args.is_empty() {
return Err(minijinja::Error::new(
minijinja::ErrorKind::TooManyArguments,
"to_dict() takes no arguments",
));
} Type guard
fn call_to_dict_safely(args: &[minijinja::Value]) -> Option<minijinja::Value> {
if args.is_empty() { Some(placeholder_provider_to_dict()) } else { None }
} Prevention
- Always call to_dict() with zero arguments
- Filter/transform the returned dict afterward rather than passing filter arguments
- Check the object's implemented method table in state.rs before adding new template calls
When it happens
Trigger: Calling `var_provider.to_dict(something)` (or `to_dict(x, y)`, etc.) from a Jinja/minijinja template instead of the zero-argument form `to_dict()`.
Common situations: Developers porting from Python dbt where dict-like helpers sometimes accept filters/keys; copying `to_dict(key=...)` idioms from other objects; thinking to_dict takes an optional filter or path argument.
Related errors
- Unknown method on VarProvider
- diff_of_two_dicts requires exactly 2 arguments
- {e}
- grants_table must be an AgateTable
- has_var requires 1 argument
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/40781e5ac2818f5d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-schemas/src/state.rs:1289
pub struct VarProvider(BTreeMap<String, minijinja::Value>);
impl VarProvider {
pub fn new(map: BTreeMap<String, minijinja::Value>) -> VarProvider {
VarProvider(map)
}
}
impl Object for VarProvider {
fn call_method(
self: &Arc<Self>,
_state: &minijinja::State<'_, '_>,
method: &str,
args: &[minijinja::Value],
_listeners: &[std::rc::Rc<dyn minijinja::listener::RenderingEventListener>],
) -> Result<minijinja::Value, minijinja::Error> {
match method {
"to_dict" => {
if !args.is_empty() {
return Err(minijinja::Error::new(
minijinja::ErrorKind::TooManyArguments,
"to_dict() takes no arguments",
));
}
Ok(minijinja::Value::from(self.0.clone()))
}
_ => Err(minijinja::Error::new(
minijinja::ErrorKind::UnknownMethod,
format!("Unknown method on VarProvider: '{method}'"),
)),
}
}
}
/// Represents the status of a model
#[derive(Debug, Clone, PartialEq, Copy)]
pub enum ModelStatus {
/// Model is enabled and successfully parsed
Enabled,View on GitHub (pinned to 0267ce9170)