{"record":{"id":"73e506d44b9c9d1e","repo":"dbt-labs/dbt-core","slug":"model-config-must-be-a-relationconfig","errorCode":null,"errorMessage":"model_config must be a RelationConfig","messagePattern":"model_config must be a RelationConfig","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/adapter/mod.rs","lineNumber":3312,"sourceCode":"    /// https://github.com/databricks/dbt-databricks/blob/7c282cabb518a5e1173222e7901896d31de8401f/dbt/adapters/databricks/impl.py#L1088\n    #[tracing::instrument(skip_all, level = \"trace\")]\n    pub fn get_relation_config(\n        &self,\n        state: &State,\n        args: &[Value],\n    ) -> Result<Value, minijinja::Error> {\n        match &self.inner {\n            Typed { adapter, .. } => {\n                let iter =\n                    ArgsIter::new(\"get_relation_config\", &[\"relation\", \"model_config\"], args);\n                let relation_val = iter.next_arg::<&Value>()?;\n                let relation = downcast_value_to_dyn_base_relation(relation_val)?;\n                let model_config = iter\n                    .next_arg::<Option<&Value>>()?\n                    .filter(|value| !value.is_none() && !value.is_undefined())\n                    .map(|value| {\n                        value.downcast_object::<RelationConfig>().ok_or_else(|| {\n                            minijinja::Error::new(\n                                minijinja::ErrorKind::InvalidArgument,\n                                \"model_config must be a RelationConfig\",\n                            )\n                        })\n                    })\n                    .transpose()?;\n                iter.finish()?;\n\n                let mut conn =\n                    adapter.borrow_tlocal_connection(Some(state), node_id_from_state(state))?;\n                let config = adapter.get_relation_config(\n                    state,\n                    conn.as_mut(),\n                    &relation,\n                    model_config.as_deref(),\n                    self.cancellation_token.clone(),\n                )?;\n                Ok(Value::from_object(config))","sourceCodeStart":3294,"sourceCodeEnd":3330,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/adapter/mod.rs#L3294-L3330","documentation":"An InvalidArgument minijinja error thrown when the optional `model_config` argument to a relation-returning callable is present but is not a RelationConfig object. The code filters out None/undefined and then downcasts the remaining Value to RelationConfig; any other object type (dict, string, relation) fails the downcast.","triggerScenarios":"Calling the adapter function with `model_config=` set to a plain dict, a string, a BaseRelation, or any Value that is not a RelationConfig instance; also occurs if the object was wrapped differently by another binding layer.","commonSituations":"Custom materializations that pass `config` dicts directly; macros forwarding `this` (a relation) as model_config; refactors that changed what `model_config` holds.","solutions":["Pass the model's RelationConfig object (e.g. `model.config` when it is a RelationConfig) as model_config.","Omit the model_config argument entirely if you have no RelationConfig — it is optional.","If you only have a dict, first build/obtain a RelationConfig from it before calling.","Check that the value is not a wrapped or foreign-language object lacking the RelationConfig downcast."],"exampleFix":"// before\nload_relation(relation, model_config={'database': 'db'})\n// after\nload_relation(relation, model_config=model.config)","handlingStrategy":"validation","validationCode":"{% if model_config is defined and model_config is not none %}\n  {# must be a RelationConfig, not a dict #}\n{% endif %}","typeGuard":"fn is_relation_config(v: &Value) -> bool {\n    v.downcast_object::<RelationConfig>().is_some()\n}","tryCatchPattern":"match value.downcast_object::<RelationConfig>() { Some(c) => ..., None => return Err(invalid_argument(\"model_config must be a RelationConfig\")) }","preventionTips":["Only pass objects known to be RelationConfig (e.g. model.config in adapter context)","Omit the optional argument rather than passing None-like dicts","Document expected argument types in custom macro signatures"],"tags":["jinja","argument-type","relation-config"],"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"}