dbt-labs/dbt-core · error · InvalidOperation
diff_of_two_dicts requires a dict_a argument
Error message
diff_of_two_dicts requires a dict_a argument
What it means
diff_of_two_dicts validates that a value for dict_a is available, either via the dict_a kwarg or the first positional argument. When neither is present the function throws this InvalidOperation error. It is a required-argument check distinct from the arity check.
Source
Thrown at crates/dbt-jinja-utils/src/functions/base.rs:614
}
}
/// A function that returns the difference between two dictionaries
/// Not documented in dbt Jinja docs, but included in base.py
pub fn diff_of_two_dicts_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,
"diff_of_two_dicts requires exactly 2 arguments",
));
}
let dict_a_arg = match (kwargs.get("dict_a"), args.first()) {
(Ok(value), _) => value,
(_, Some(value)) => value,
_ => {
return Err(Error::new(
ErrorKind::InvalidOperation,
"diff_of_two_dicts requires a dict_a argument",
));
}
}
.clone();
let dict_b_arg = match (kwargs.get("dict_b"), args.get(1)) {
(Ok(value), _) => value,
(_, Some(value)) => value,
_ => {
return Err(Error::new(
ErrorKind::InvalidOperation,
"diff_of_two_dicts requires a dict_b argument",
));
}
}
.clone();View on GitHub (pinned to 0267ce9170)
Solutions
- Provide the first dict positionally: diff_of_two_dicts(a, b)
- Or pass it explicitly: diff_of_two_dicts(dict_a=a, dict_b=b)
- Check that the variable holding dict_a is defined and not undefined at render time
Example fix
// before
{% set diff = diff_of_two_dicts(dict_b=other) %}
// after
{% set diff = diff_of_two_dicts(dict_a=my_dict, dict_b=other) %} Defensive patterns
Strategy: validation
Validate before calling
{% if dict_a is not defined %}
{{ exceptions.raise_compiler_error('dict_a is required before diff_of_two_dicts in ' ~ this) }}
{% endif %} Type guard
{% macro is_dict(x) %}{{ return(x is defined and x is mapping) }}{% endmacro %} Prevention
- When mixing kwargs and positionals, always provide dict_a explicitly
- Check variable definitions with `is defined` before helper calls
- Keep argument order consistent across a project
When it happens
Trigger: Calling diff_of_two_dicts() with zero positional args and no dict_a kwarg, or calling it with only dict_b=... supplied. Notably this fires with 2+ args only if lookup order breaks, but practically it fires on the missing-dict_a call shape.
Common situations: Kwargs/positional mixing mistakes: developers pass dict_b= keyword only and forget dict_a; templates built programmatically where the first positional slot ends up empty.
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 a dict_b argument
- write function requires payload argument
- describe_dynamic_table is not supported by the {} adapter
- describe_interactive_table is not supported by the {} adapte
- get_csv_data requires agate_table argument
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/608416e6c37e8661.
Report an issue: GitHub.