dbt-labs/dbt-core · error · minijinja::Error
Unknown method on VarProvider
Error message
Unknown method on VarProvider: '{method}' What it means
The VarProvider minijinja method dispatcher only implements 'to_dict'; every other method name falls into the `_` catch-all arm which raises ErrorKind::UnknownMethod with the requested name interpolated. Any method call other than to_dict() on this object is rejected at template render time.
Solutions
- Check the method name against the implemented set in the match — only `to_dict` exists
- Use `var_provider.to_dict()` and then use standard Jinja dict operations on the result
- Add the desired method to the match arm in state.rs if the object should support it
Example fix
// before (template)
{% set my_var = var_provider.get('my_var') %}
// after
{% set all_vars = var_provider.to_dict() %}
{% set my_var = all_vars.get('my_var') %} Defensive patterns
Strategy: type-guard
Validate before calling
// In template: check the method exists before use
// {% if var_provider.to_dict is defined %}...{% endif %}
// In Rust, whitelist allowed method names before dispatch:
const METHODS: &[&str] = &["to_dict"];
assert!(METHODS.contains(&method), "unsupported method: {method}"); Type guard
fn is_supported_var_provider_method(method: &str) -> bool {
matches!(method, "to_dict")
} Try / catch
match result {
Err(e) if e.kind() == minijinja::ErrorKind::UnknownMethod => {
// fall back to var_provider.to_dict() and dict access
}
other => other?,
} Prevention
- Only call to_dict() on VarProvider values; use plain Jinja dict operations afterward
- Watch for typos: to_dict vs to_dicts vs as_dict
- When the provider gains new methods, keep the match arm in state.rs as the source of truth
When it happens
Trigger: Calling any method other than `to_dict()` on a VarProvider value from a minijinja template, e.g. `var_provider.get('my_var')` or `var_provider.keys()` — typo'd names like `to_dicts` also land here.
Common situations: Template code assuming VarProvider is a full dict/object with dict methods (get, keys, items); typos in method names; API changes where a method was removed or renamed.
Related errors
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/ef8d7de0bd629d95.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-schemas/src/state.rs:1296
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,
/// Model is disabled by configuration
Disabled,
/// Model failed to parse
ParsingFailed,
}
#[cfg(test)]View on GitHub (pinned to 0267ce9170)