{"record":{"id":"40781e5ac2818f5d","repo":"dbt-labs/dbt-core","slug":"to-dict-takes-no-arguments","errorCode":null,"errorMessage":"to_dict() takes no arguments","messagePattern":"to_dict\\(\\) takes no arguments","errorType":"validation","errorClass":"minijinja::Error","httpStatus":null,"severity":"error","filePath":"crates/dbt-schemas/src/state.rs","lineNumber":1289,"sourceCode":"pub struct VarProvider(BTreeMap<String, minijinja::Value>);\n\nimpl VarProvider {\n    pub fn new(map: BTreeMap<String, minijinja::Value>) -> VarProvider {\n        VarProvider(map)\n    }\n}\nimpl Object for VarProvider {\n    fn call_method(\n        self: &Arc<Self>,\n        _state: &minijinja::State<'_, '_>,\n        method: &str,\n        args: &[minijinja::Value],\n        _listeners: &[std::rc::Rc<dyn minijinja::listener::RenderingEventListener>],\n    ) -> Result<minijinja::Value, minijinja::Error> {\n        match method {\n            \"to_dict\" => {\n                if !args.is_empty() {\n                    return Err(minijinja::Error::new(\n                        minijinja::ErrorKind::TooManyArguments,\n                        \"to_dict() takes no arguments\",\n                    ));\n                }\n                Ok(minijinja::Value::from(self.0.clone()))\n            }\n            _ => Err(minijinja::Error::new(\n                minijinja::ErrorKind::UnknownMethod,\n                format!(\"Unknown method on VarProvider: '{method}'\"),\n            )),\n        }\n    }\n}\n/// Represents the status of a model\n#[derive(Debug, Clone, PartialEq, Copy)]\npub enum ModelStatus {\n    /// Model is enabled and successfully parsed\n    Enabled,","sourceCodeStart":1271,"sourceCodeEnd":1307,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-schemas/src/state.rs#L1271-L1307","documentation":"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.","triggerScenarios":"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()`.","commonSituations":"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.","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"],"exampleFix":"// before (template)\n{% set vars = var_provider.to_dict('schema') %}\n// after\n{% set vars = var_provider.to_dict() %}\n{% set schema_vars = vars.get('schema', {}) %}","handlingStrategy":"validation","validationCode":"// In template/macros, guard before calling:\n// {% if caller_args | length > 0 %}{% raise 'to_dict() takes no arguments' %}{% endif %}\n// In Rust, before invoking the method dispatch:\nif !args.is_empty() {\n    return Err(minijinja::Error::new(\n        minijinja::ErrorKind::TooManyArguments,\n        \"to_dict() takes no arguments\",\n    ));\n}","typeGuard":"fn call_to_dict_safely(args: &[minijinja::Value]) -> Option<minijinja::Value> {\n    if args.is_empty() { Some(placeholder_provider_to_dict()) } else { None }\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["minijinja","template","varprovider","argument-count"],"backgroundTag":"too-many-arguments","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}