{"record":{"id":"6a3be3f2e9f5ae12","repo":"dbt-labs/dbt-core","slug":"zip-strict-requires-all-arguments-to-be-iterable","errorCode":null,"errorMessage":"zip_strict requires all arguments to be iterable","messagePattern":"zip_strict requires all arguments to be iterable","errorType":"validation","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/functions/base.rs","lineNumber":898,"sourceCode":"/// {% set list2 = ['a', 'b', 'c'] %}\n/// {% set pairs = zip_strict(list1, list2) %}\n/// -- Returns [(1, 'a'), (2, 'b'), (3, 'c')] or fails if inputs aren't iterable or lengths differ\n/// ```\npub fn zip_strict_fn() -> impl Fn(&[Value], Kwargs) -> Result<Value, Error> {\n    move |args: &[Value], _kwargs: Kwargs| -> Result<Value, Error> {\n        if args.len() < 2 {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                \"zip_strict requires two or more iterable arguments\",\n            ));\n        }\n\n        let mut iterators: Vec<Vec<Value>> = Vec::new();\n        for arg in args {\n            match arg.try_iter() {\n                Ok(iter) => iterators.push(iter.collect()),\n                Err(_) => {\n                    return Err(Error::new(\n                        ErrorKind::InvalidOperation,\n                        \"zip_strict requires all arguments to be iterable\",\n                    ));\n                }\n            }\n        }\n\n        // Find shortest length (Python's zip behavior)\n        let min_len = iterators.iter().map(|v| v.len()).min().unwrap_or(0);\n\n        let mut zipped = Vec::new();\n        for i in 0..min_len {\n            let tuple: Vec<Value> = iterators.iter().map(|iter| iter[i].clone()).collect();\n            zipped.push(Value::from(tuple));\n        }\n\n        Ok(Value::from_iter(zipped))\n    }","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/functions/base.rs#L880-L916","documentation":"`zip_strict` requires every positional argument to be iterable; this error is raised when any argument fails `try_iter()`. Non-iterable values such as strings used as scalars, numbers, booleans, dicts (in some renderings), or undefined values cannot be zipped, so the function fails fast with this message instead of producing broken output.","triggerScenarios":"Calling `zip_strict(5, list)` or `zip_strict(dict, list)` — any argument whose `Value::try_iter()` returns Err, typically a scalar number, boolean, or undefined value passed where a list was expected.","commonSituations":"A variable intended to be a list is undefined because a config key was missing, a model returned a scalar instead of a column list, or an integer count was passed instead of a `range()` sequence.","solutions":["Check each argument is a list/sequence before calling, e.g. wrap scalars in a list: `zip_strict([x], my_list)`","Verify the source variables are defined: render them with `log()` or `{{ debug() }}` before the zip","Replace a scalar count with an iterable: `range(n)` instead of `n`"],"exampleFix":"// before\n{% set pairs = zip_strict(n, names) %}\n// after\n{% set pairs = zip_strict(range(n), names) %}","handlingStrategy":"type-guard","validationCode":"{% if list1 is not iterable or list2 is not iterable %}{{ log('non-iterable input to zip_strict') }}{% endif %}","typeGuard":"{% macro as_list(v) %}{% if v is iterable and v is not string %}{{ v }}{% else %}{{ [v] }}{% endif %}{% endmacro %}","tryCatchPattern":"// Jinja has no try/catch; validate before calling:\n{% if x is iterable %}{% set pairs = zip_strict(x, y) %}{% else %}{% set pairs = [] %}{% endif %}","preventionTips":["Wrap scalars in [ ] before zipping","Use var('name', default=[]) to guarantee lists","Check upstream queries return sequences, not scalars"],"tags":["jinja","iterable","type-error"],"backgroundTag":"type-mismatch","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"}