dbt-labs/dbt-core · error · InvalidOperation
local_md5 requires exactly 1 argument
Error message
local_md5 requires exactly 1 argument
What it means
`local_md5` computes the MD5 hash of a string locally (no warehouse round-trip) and requires exactly one positional argument. Calls with zero or with two-plus arguments are rejected with this error to keep parity with dbt-core's single-argument signature.
Solutions
- Pass exactly one string argument
- Concatenate multiple fields first: `local_md5(field1 ~ field2)`
- Check the call site signature matches the macro/function definition
Example fix
// before
{% set h = local_md5(col1, col2) %}
// after
{% set h = local_md5(col1 ~ col2) %} Defensive patterns
Strategy: validation
Validate before calling
{% if fields | length != 1 %}{{ log('local_md5 takes exactly 1 arg') }}{% endif %} Prevention
- Pass exactly one string argument
- Concatenate multiple fields before hashing
- Keep macro call sites in sync with definitions
When it happens
Trigger: Calling `{{ local_md5() }}` or `{{ local_md5(a, b) }}` — any argument count other than 1.
Common situations: Building hash keys from multiple fields and forgetting to concatenate them first, or a macro parameter list drifting out of sync with the call site.
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's argument must be a string
- 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/c4a18c53141f6ee5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-jinja-utils/src/functions/base.rs:1035
Ok(Value::from(""))
}
}
/// Calculate an MD5 hash of the given string.
///
/// Args:
/// value: String to hash
///
/// Example:
/// ```jinja
/// {% set hash = local_md5("hello") %}
/// -- Returns "5d41402abc4b2a76b9719d911017c592"
/// ```
pub fn local_md5_fn() -> impl Fn(&[Value], Kwargs) -> Result<Value, Error> {
move |args: &[Value], _kwargs: Kwargs| -> Result<Value, Error> {
if args.len() != 1 {
return Err(Error::new(
ErrorKind::InvalidOperation,
"local_md5 requires exactly 1 argument",
));
}
let value = args[0].as_str().ok_or_else(|| {
Error::new(
ErrorKind::InvalidOperation,
"local_md5's argument must be a string",
)
})?;
// Create MD5 hasher
let result = format!("{:x}", md5::compute(value.as_bytes()));
Ok(Value::from(result))
}
}
/// Parse a dictionary of lists into a BTreeMap<String, Vec<String>>View on GitHub (pinned to 0267ce9170)