{"record":{"id":"03c2b05fca716620","repo":"dbt-labs/dbt-core","slug":"invalid-arguments-to-doc-macro","errorCode":null,"errorMessage":"Invalid arguments to doc macro","messagePattern":"Invalid arguments to doc macro","errorType":"validation","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/functions/base.rs","lineNumber":248,"sourceCode":"        // because model/source/column descriptions still render through it.\n        if self.strict && (args.kwargs_len() != 0 || !(1..=2).contains(&args.positional_len())) {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                \"doc() takes one or two positional string arguments\",\n            ));\n        }\n        let (arg1, arg2) = if self.strict {\n            // Both args are annotated `str`, so no coercion either.\n            let package_or_name = args.get::<Arc<str>>(\"\")?.to_string();\n            let name = if args.positional_len() == 0 {\n                None\n            } else {\n                Some(args.get::<Arc<str>>(\"\")?.to_string())\n            };\n            (package_or_name, name)\n        } else {\n            let arg1 = args.get::<String>(\"\").map_err(|_| {\n                Error::new(\n                    ErrorKind::InvalidOperation,\n                    \"Invalid arguments to doc macro\",\n                )\n            })?;\n            (arg1, args.get_optional::<String>(\"\"))\n        };\n\n        let (doc, target_package, doc_name) = match &arg2 {\n            // Two arguments: explicit package and doc name\n            Some(doc_name) => (\n                self.lookup_doc(&arg1, doc_name),\n                arg1.clone(),\n                doc_name.clone(),\n            ),\n            // One argument: search the configured package precedence, then any package\n            None => {\n                let doc = self\n                    .package_search_order","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/functions/base.rs#L230-L266","documentation":"In lenient (non-strict) mode, doc() still requires its first positional argument to be a string; if args.get::<String>(\"\") fails, this InvalidOperation error replaces the low-level conversion error. It indicates the doc macro was called with no usable first argument.","triggerScenarios":"Calling {{ doc() }} with no arguments, or with a non-string first argument (e.g. a number, list, or None) while strict mode is disabled.","commonSituations":"Templated calls like {{ doc(my_var) }} where my_var is undefined or non-string; refactored macros that dropped the doc name argument.","solutions":["Pass a string doc name as the first argument: {{ doc('my_doc') }}.","Ensure any variable used as the doc name is defined and renders to a string.","Coerce or default the variable: {{ doc(my_var | default('fallback_doc')) }}.","Enable strict mode if you want the clearer argument-count diagnostics."],"exampleFix":"// before\n{{ doc() }}\n// after\n{{ doc('order_status') }}","handlingStrategy":"validation","validationCode":"{% if doc_name is not string %}{% do exceptions.raise_compiler_error('doc name must be a string') %}{% endif %}","typeGuard":null,"tryCatchPattern":"{% set doc_name_str = doc_name | default('') | string %}\n{{ doc(doc_name_str) if doc_name_str else '' }}","preventionTips":["Ensure variables interpolated into doc() are defined strings.","Default template variables: {{ doc(my_var | default('fallback')) }}.","Never call doc() with zero arguments."],"tags":["jinja","doc","arguments","type-mismatch"],"backgroundTag":"invalid-argument","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}