{"record":{"id":"d98bf79edd235885","repo":"dbt-labs/dbt-core","slug":"primary-key-has-a-wrong-type-in-staticbaserelati","errorCode":null,"errorMessage":"'primary_key' has a wrong type in StaticBaseRelationObject: '{primary_key}'","messagePattern":"'primary_key' has a wrong type in StaticBaseRelationObject: '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/relation/relation_object.rs","lineNumber":877,"sourceCode":"        )\n    }\n\n    fn scd_args(&self, args: &[Value]) -> Result<Value, minijinja::Error> {\n        let iter = ArgsIter::new(\"Relation.scd_args\", &[], args);\n        let primary_key = iter.next_kwarg::<Value>(\"primary_key\")?;\n        let updated_at = iter.next_kwarg::<String>(\"updated_at\")?;\n        iter.finish()?;\n\n        let mut scd_args = vec![];\n        match primary_key.kind() {\n            ValueKind::Seq => {\n                scd_args.extend(primary_key.try_iter()?.enumerate().map(|s| s.1.to_string()));\n            }\n            ValueKind::String => {\n                scd_args.push(primary_key.as_str().unwrap().to_string());\n            }\n            _ => {\n                return Err(minijinja::Error::new(\n                    minijinja::ErrorKind::InvalidOperation,\n                    format!(\n                        \"'primary_key' has a wrong type in StaticBaseRelationObject: '{primary_key}'\"\n                    ),\n                ));\n            }\n        }\n        scd_args.push(updated_at);\n        Ok(Value::from(scd_args))\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use crate::relation::factory::create_static_relation;\n\n    use super::*;\n    use dbt_schemas::schemas::relations::DEFAULT_RESOLVED_QUOTING;","sourceCodeStart":859,"sourceCodeEnd":895,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/relation/relation_object.rs#L859-L895","documentation":"`scd_args` accepts a `primary_key` that is either a list/iterable of columns or a single string. If the value is any other type (e.g. a dict, boolean, or number), the dispatcher raises this InvalidOperation error including the offending value's string form.","triggerScenarios":"Calling `relation.scd_args(...)` (snapshot SCD argument building) where the `primary_key` argument resolves to a non-string, non-list Jinja value — e.g. a dict from `config.get('unique_key')` or a boolean.","commonSituations":"Snapshot configs where `unique_key` is a dict or None-derived value instead of a string or list of strings; macros passing `config.model.unique_key` through unmodified when it has an unexpected shape.","solutions":["Ensure `unique_key`/`primary_key` in the snapshot config is a string or a list of strings.","Coerce the value before calling: wrap a single column as a one-element list or `| string`.","Inspect the printed `{primary_key}` in the message to see the actual value and fix its source config."],"exampleFix":"// before\n{{ relation.scd_args(config.model.unique_key) }}  // unique_key is a dict\n// after\n{% set pk = config.model.unique_key %}\n{% if pk is not string and pk is not sequence %}\n  {% set pk = [pk | string] %}\n{% endif %}\n{{ relation.scd_args(pk) }}","handlingStrategy":"validation","validationCode":"{% set pk = config.get('unique_key') %}\n{% if pk is string or pk is sequence and pk is not string %}\n  {{ relation.scd_args(pk) }}\n{% else %}\n  {% do exceptions.raise_compiler_error('unique_key must be a string or list of strings') %}\n{% endif %}","typeGuard":"{% macro is_valid_pk(pk) %}\n  {{ return(pk is string or (pk is sequence and pk is not mapping and pk is not string)) }}\n{% endmacro %}","tryCatchPattern":null,"preventionTips":["Keep `unique_key` configs as strings or lists of strings only.","Coerce single non-string values with `| string` before calling scd_args.","Add a schema check in CI for snapshot configs."],"tags":["jinja","type-mismatch","snapshot","primary-key"],"backgroundTag":"invalid-argument-value","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"}