dbt-labs/dbt-core · error · minijinja::Error (InvalidOperation)
Expected at least one argument
Error message
Expected at least one argument
What it means
`assert_minijinja` evaluates a Jinja expression as an assertion and requires at least one argument — the expression to assert. An optional second argument supplies the failure message. The library throws this `InvalidOperation` error when the function is invoked with zero arguments, since there is nothing to assert.
Solutions
- Pass at least the expression to assert: `assert(expression)` or `{{ assert(1 == 1, 'sanity check') }}`.
- Add an optional second argument as the assertion failure message.
- Guard macro-generated calls so the expression is always interpolated before the assert call is emitted.
Example fix
-- before
{% do assert() %}
-- after
{% do assert(model.row_count > 0, 'model returned no rows') %}
Defensive patterns
Strategy: validation
Validate before calling
{% if assertion_expr is undefined %}
{{ exceptions.raise_compiler_error('assert() requires an expression argument') }}
{% else %}
{% do assert(assertion_expr, 'failed') %}
{% endif %} Prevention
- Never emit assert() with an empty argument list from generated templates.
- Always pass an explicit failure message as the second argument.
- Interpolate variables before the call so undefined values surface early.
When it happens
Trigger: Calling `{% do assert() %}` / `assert_minijinja()` with no arguments in a template or test that wires the assert function.
Common situations: Empty assert calls left behind while editing tests; macro-generated asserts where the expression variable was undefined and dropped from the call; copy-pasted generic test templates.
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
- submit_python_job expects 2 arguments, got
- adapter not found in context
- adapter should be configured for the parse phase
- agate_table must be an agate.Table
- Argument must be a string
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/f460c934f167717b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-jinja-utils/src/utils.rs:92
pub fn as_bool(args: Value) -> Result<Value, Error> {
let input = args.to_string();
match input.parse::<i64>() {
Ok(int_value) => Ok(Value::from(int_value != 0)),
Err(_) => match input.parse::<f64>() {
Ok(float_value) => Ok(Value::from(!float_value.is_nan() && float_value != 0.0)),
Err(_) => match input.to_ascii_lowercase().as_str() {
"true" => Ok(Value::from(true)),
"false" => Ok(Value::from(false)),
_ => Ok(Value::from(!input.is_empty())),
},
},
}
}
/// Asserts a condition using Jinja
pub fn assert_minijinja(_state: &State, args: Rest<Value>) -> Result<Value, Error> {
if args.is_empty() {
return Err(Error::new(
ErrorKind::InvalidOperation,
"Expected at least one argument",
));
}
let expr = args[0].clone();
let message = args.get(1).map_or_else(String::new, |v| v.to_string());
let condition = as_bool(expr)?;
if condition == Value::from(false) {
eprintln!("error: {} assertion failed", &message);
}
Ok(Value::from(""))
}
/// Logs a message using Jinja
pub fn log_minijinja(state: &State, args: Rest<Value>) -> String {
let debug_str = debug(state, args);
eprintln!("log: {}", &debug_str);
"".to_owned()View on GitHub (pinned to 0267ce9170)