{"record":{"id":"2d75a946ece5f76a","repo":"dbt-labs/dbt-core","slug":"has-var-requires-1-argument","errorCode":null,"errorMessage":"has_var requires 1 argument","messagePattern":"has_var requires 1 argument","errorType":"exception","errorClass":"minijinja::Error (InvalidOperation)","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-vars/src/var.rs","lineNumber":115,"sourceCode":"    fn missing_var_error<M>(package_name: &str, var_name: &str, vars_lookup: &M) -> Error\n    where\n        M: Serialize + ?Sized,\n    {\n        Error::new(\n            ErrorKind::InvalidOperation,\n            format!(\n                \"Required var '{}' not found in config:\\nVars supplied to {} = {}\",\n                var_name,\n                package_name,\n                serde_json::to_string_pretty(vars_lookup).unwrap()\n            ),\n        )\n    }\n\n    /// Common handler for `has_var`.\n    fn call_has_var(&self, state: &State<'_, '_>, args: &[Value]) -> Result<Value, Error> {\n        if args.is_empty() {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                \"has_var requires 1 argument\",\n            ));\n        }\n        let var_name = args[0].as_str().ok_or_else(|| {\n            Error::new(\n                ErrorKind::InvalidOperation,\n                \"argument 'name' to has_var() has incompatible type; value is not a string\",\n            )\n        })?;\n        let present = self.contains_var(state, var_name)?;\n        Ok(Value::from(present))\n    }\n\n    /// Common implementation for `Object::call`.\n    fn call_impl(\n        self: &Arc<Self>,\n        state: &State<'_, '_>,","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-vars/src/var.rs#L97-L133","documentation":"The `has_var()` Jinja method checks whether a named var exists in the configuration. It requires exactly one argument; `call_has_var` rejects a call with an empty argument list with this error. (Extra arguments beyond the first are not rejected here, but zero arguments always is.)","triggerScenarios":"Calling `{{ has_var() }}` with no arguments — e.g. forgetting the name entirely, or intending a zero-argument existence probe of all vars.","commonSituations":"Typos that drop the argument (`has_var('x',)` still passes args, but `has_var()` doesn't); misunderstanding `has_var` as taking a dict or package argument; copy-paste removal of the argument during refactoring.","solutions":["Pass the var name: `{{ has_var('my_var') }}`.","If checking existence per-package, ensure your caller passes the resolved name string as the single argument.","Review the call site for an accidentally deleted or commented-out argument."],"exampleFix":"// before (Jinja)\n{% if has_var() %}\n// after\n{% if has_var('my_var') %}","handlingStrategy":"validation","validationCode":"{% if not name %}{{ exceptions.raise_compiler_error('has_var requires a name') }}{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass exactly one string argument to has_var","Wrap has_var in a project macro that enforces the signature","Check call sites after refactors that touch the argument"],"tags":["jinja","argument-count","has-var","dbt"],"backgroundTag":"missing-required-argument","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}