{"record":{"id":"5d9d4d5aab26c28b","repo":"dbt-labs/dbt-core","slug":"print-requires-at-least-one-argument-a-message-to","errorCode":null,"errorMessage":"print requires at least one argument (a message to print)","messagePattern":"print requires at least one argument \\(a message to print\\)","errorType":"validation","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/functions/base.rs","lineNumber":931,"sourceCode":"        }\n\n        Ok(Value::from_iter(zipped))\n    }\n}\n\n/// 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, &[])","sourceCodeStart":913,"sourceCodeEnd":949,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/functions/base.rs#L913-L949","documentation":"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.","triggerScenarios":"Calling `{{ print() }}` with no positional arguments in a Jinja template or macro.","commonSituations":"Dynamically building a print call from a variable that ended up empty/undefined, or translating dbt macros where the message argument was accidentally dropped.","solutions":["Pass a message argument: `{{ print(\"Hello world!\") }}`","If the message may be empty, provide a default: `{{ print(msg or \"(no message)\") }}`"],"exampleFix":"// before\n{{ print() }}\n// after\n{{ print(\"Hello world!\") }}","handlingStrategy":"validation","validationCode":"{% if msg is not defined %}{% set msg = '(no message)' %}{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply the message argument to print","Provide a default with var('msg', '') before printing","Avoid building print calls from possibly-empty variables"],"tags":["jinja","argument-count","print"],"backgroundTag":"missing-required-argument","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"}