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

  1. Join multiple values into one string first: `{{ print(a ~ " " ~ b) }}`
  2. 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

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


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 print

View on GitHub (pinned to 0267ce9170)