{"record":{"id":"c446ecf82207e85c","repo":"dbt-labs/dbt-core","slug":"print-accepts-only-one-argument","errorCode":null,"errorMessage":"print accepts only one argument","messagePattern":"print accepts only one argument","errorType":"validation","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/functions/base.rs","lineNumber":937,"sourceCode":"/// Print a message to the log file and stdout.\n///\n/// Args:\n///     msg: Message to print\n///\n/// Example:\n/// ```jinja\n/// {{ print(\"Hello world!\") }}\n/// ```\npub fn print_fn() -> impl Fn(&State<'_, '_>, &[Value], Kwargs) -> Result<Value, Error> {\n    move |state: &State<'_, '_>, args: &[Value], _kwargs: Kwargs| -> Result<Value, Error> {\n        if args.is_empty() {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                \"print requires at least one argument (a message to print)\",\n            ));\n        }\n        if args.len() > 1 {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                \"print accepts only one argument\",\n            ));\n        }\n\n        // Format the message using Display formatting (not Debug) to match dbt's behavior\n        // This ensures strings aren't wrapped in quotes (e.g., \"string\" instead of \"'string'\")\n        let msg = format!(\"{}\", args[0]);\n\n        // Get metadata for the event\n        let current_package_name = state\n            .lookup(TARGET_PACKAGE_NAME, &[])\n            .and_then(|v| v.as_str().map(|s| s.to_string()));\n        let line = state.current_span().start_line;\n        let column = state.current_span().start_col;\n        let cur_file_path = state.current_path().to_str().map(str::to_string);\n\n        // Emit UserLogMessage event for print","sourceCodeStart":919,"sourceCodeEnd":955,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/functions/base.rs#L919-L955","documentation":"`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.","triggerScenarios":"Calling `{{ print(a, b) }}` or `{{ print(\"x\", var) }}` with two or more positional arguments.","commonSituations":"Porting Python `print(a, b, sep=...)` habits into Jinja, or concatenating debug output without joining the pieces first.","solutions":["Join multiple values into one string first: `{{ print(a ~ \" \" ~ b) }}`","Use string formatting to combine values: `{{ print(\"a={} b={}\".format(a, b)) }}`"],"exampleFix":"// before\n{{ print(\"count:\", n) }}\n// after\n{{ print(\"count: \" ~ n) }}","handlingStrategy":"validation","validationCode":"{% set parts = [a, b] %}{% set msg = parts | join(' ') %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["jinja","argument-count","print"],"backgroundTag":"invalid-argument-count","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}