dbt-labs/dbt-core · error · InvalidOperation
print requires at least one argument (a message to print)
Error message
print requires at least one argument (a message to print)
What it means
The `print` Jinja function requires at least one positional argument — the message to print. Called with zero arguments it cannot produce output, so it raises this InvalidOperation error. The function exists to emulate dbt's `print()` (log) behavior inside rendered templates.
Solutions
- Pass a message argument: `{{ print("Hello world!") }}`
- If the message may be empty, provide a default: `{{ print(msg or "(no message)") }}`
Example fix
// before
{{ print() }}
// after
{{ print("Hello world!") }} Defensive patterns
Strategy: validation
Validate before calling
{% if msg is not defined %}{% set msg = '(no message)' %}{% endif %} Prevention
- Always supply the message argument to print
- Provide a default with var('msg', '') before printing
- Avoid building print calls from possibly-empty variables
When it happens
Trigger: Calling `{{ print() }}` with no positional arguments in a Jinja template or macro.
Common situations: Dynamically building a print call from a variable that ended up empty/undefined, or translating dbt macros where the message argument was accidentally dropped.
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
- print accepts only one argument
- diff_of_two_dicts requires exactly 2 arguments
- has_var requires 1 argument
- local_md5 requires exactly 1 argument
- render requires exactly one argument (the string to render)
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/5d9d4d5aab26c28b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-jinja-utils/src/functions/base.rs:931
}
Ok(Value::from_iter(zipped))
}
}
/// Print a message to the log file and stdout.
///
/// Args:
/// msg: Message to print
///
/// Example:
/// ```jinja
/// {{ print("Hello world!") }}
/// ```
pub fn print_fn() -> impl Fn(&State<'_, '_>, &[Value], Kwargs) -> Result<Value, Error> {
move |state: &State<'_, '_>, args: &[Value], _kwargs: Kwargs| -> Result<Value, Error> {
if args.is_empty() {
return Err(Error::new(
ErrorKind::InvalidOperation,
"print requires at least one argument (a message to print)",
));
}
if args.len() > 1 {
return Err(Error::new(
ErrorKind::InvalidOperation,
"print accepts only one argument",
));
}
// Format the message using Display formatting (not Debug) to match dbt's behavior
// This ensures strings aren't wrapped in quotes (e.g., "string" instead of "'string'")
let msg = format!("{}", args[0]);
// Get metadata for the event
let current_package_name = state
.lookup(TARGET_PACKAGE_NAME, &[])View on GitHub (pinned to 0267ce9170)