dbt-labs/dbt-core · error · InvalidOperation
zip_strict requires two or more iterable arguments
Error message
zip_strict requires two or more iterable arguments
What it means
This error is thrown by the `zip_strict` Jinja helper in dbt-jinja-utils when the function is invoked with fewer than two positional arguments. `zip_strict` mirrors dbt-core's strict zip: it pairs elements from multiple iterables and fails if lengths differ. The library enforces a minimum of two iterables because zipping a single list has no meaningful pairing semantics.
Solutions
- Pass at least two iterable arguments to zip_strict, e.g. `zip_strict(list1, list2)`
- If you only need to iterate one list, use a plain `{% for %}` loop or `zip(list, range(...))` instead
- Log/inspect the rendered arguments just before the call to confirm both lists are defined and non-empty
Example fix
// before
{% set pairs = zip_strict(my_list) %}
// after
{% set pairs = zip_strict(my_list, other_list) %} Defensive patterns
Strategy: validation
Validate before calling
{% if lists | length < 2 %}{{ exceptions.raise_compiler_error('zip_strict needs 2+ lists') }}{% endif %} Type guard
{% macro ensure_zip_args(*lists) %}{{ raise_compiler_error('need 2+') if lists | length < 2 }}{% endmacro %} Prevention
- Always pass two or more lists to zip_strict
- Use plain zip or a for-loop when iterating a single list
- Sanity-check variables with log() before zipping
When it happens
Trigger: Calling `zip_strict(list1)` or `zip_strict()` in a Jinja template — i.e. passing 0 or 1 positional arguments to the registered base function.
Common situations: Refactoring a template that previously used a single-list helper, copying a dbt macro that assumed `zip` semantics with one list, or accidentally shadowing a variable so only one list argument is rendered.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- diff_of_two_dicts requires exactly 2 arguments
- has_var requires 1 argument
- local_md5 requires exactly 1 argument
- print accepts only one argument
- print requires at least one argument (a message to print)
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/7d13ee3fe38f83c1.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-jinja-utils/src/functions/base.rs:887
}
}
/// Strict version of zip() that fails if any input is not iterable or the iterables differ in length.
///
/// Args:
/// *iterables: Two or more iterables
///
/// Example:
/// ```jinja
/// {% set list1 = [1, 2, 3] %}
/// {% set list2 = ['a', 'b', 'c'] %}
/// {% set pairs = zip_strict(list1, list2) %}
/// -- Returns [(1, 'a'), (2, 'b'), (3, 'c')] or fails if inputs aren't iterable or lengths differ
/// ```
pub fn zip_strict_fn() -> impl Fn(&[Value], Kwargs) -> Result<Value, Error> {
move |args: &[Value], _kwargs: Kwargs| -> Result<Value, Error> {
if args.len() < 2 {
return Err(Error::new(
ErrorKind::InvalidOperation,
"zip_strict requires two or more iterable arguments",
));
}
let mut iterators: Vec<Vec<Value>> = Vec::new();
for arg in args {
match arg.try_iter() {
Ok(iter) => iterators.push(iter.collect()),
Err(_) => {
return Err(Error::new(
ErrorKind::InvalidOperation,
"zip_strict requires all arguments to be iterable",
));
}
}
}
View on GitHub (pinned to 0267ce9170)