dbt-labs/dbt-core · error · InvalidOperation
print accepts only one argument
Error message
print accepts only one argument
What it means
`print` accepts exactly one positional argument; when more than one is supplied it raises this error. Unlike Python's `print`, this implementation formats a single value with Display formatting to match dbt's behavior, so multi-argument calls are rejected rather than silently concatenated.
Solutions
- Join multiple values into one string first: `{{ print(a ~ " " ~ b) }}`
- Use string formatting to combine values: `{{ print("a={} b={}".format(a, b)) }}`
Example fix
// before
{{ print("count:", n) }}
// after
{{ print("count: " ~ n) }} Defensive patterns
Strategy: validation
Validate before calling
{% set parts = [a, b] %}{% set msg = parts | join(' ') %} Prevention
- Join multiple values with ~ or join(' ') before printing
- Remember print takes exactly one argument
- Grep templates for print( with commas to catch multi-arg calls
When it happens
Trigger: Calling `{{ print(a, b) }}` or `{{ print("x", var) }}` with two or more positional arguments.
Common situations: Porting Python `print(a, b, sep=...)` habits into Jinja, or concatenating debug output without joining the pieces first.
Related errors
- print requires at least one argument (a message to print)
- 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/c446ecf82207e85c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-jinja-utils/src/functions/base.rs:937
/// 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, &[])
.and_then(|v| v.as_str().map(|s| s.to_string()));
let line = state.current_span().start_line;
let column = state.current_span().start_col;
let cur_file_path = state.current_path().to_str().map(str::to_string);
// Emit UserLogMessage event for printView on GitHub (pinned to 0267ce9170)