{"record":{"id":"0675ab72ba406d6b","repo":"dbt-labs/dbt-core","slug":"relation-must-be-an-object","errorCode":null,"errorMessage":"relation must be an object","messagePattern":"relation must be an object","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/cast_util.rs","lineNumber":19,"sourceCode":"//! A set of util functions for casting from/to Value\nuse crate::relation::RelationObject;\n\nuse dbt_schemas::schemas::relations::base::BaseRelation;\n\nuse std::file;\nuse std::sync::Arc;\n\npub const THIS_RELATION_KEY: &str = \"__this__\";\n\npub fn downcast_value_to_dyn_base_relation(\n    value: &minijinja::Value,\n) -> Result<Arc<dyn BaseRelation>, minijinja::Error> {\n    if let Some(relation_object) = value.downcast_object::<RelationObject>() {\n        Ok(relation_object.inner())\n    } else if let Some(relation_object) = value\n        .as_object()\n        .ok_or_else(|| {\n            minijinja::Error::new(\n                minijinja::ErrorKind::InvalidOperation,\n                \"relation must be an object\",\n            )\n        })?\n        .get_value(&minijinja::Value::from(THIS_RELATION_KEY))\n    {\n        Ok(relation_object\n            .downcast_object::<RelationObject>()\n            .ok_or_else(|| {\n                minijinja::Error::new(\n                    minijinja::ErrorKind::InvalidOperation,\n                    \"this must be a BaseRelation object\",\n                )\n            })?\n            .inner())\n    } else {\n        Err(minijinja::Error::new(\n            minijinja::ErrorKind::InvalidOperation,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/cast_util.rs#L1-L37","documentation":"downcast_value_to_dyn_base_relation received a minijinja Value that is not an object at all (as_object() returned None) — the argument passed from Jinja to relation-taking adapter methods (drop_relation, truncate_relation, rename_relation, expand_target_column_types, cache handling) is a scalar/string/undefined rather than a relation wrapper.","triggerScenarios":"Thrown at crates/dbt-adapter/src/cast_util.rs:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an actual relation object (api.Relation.create(...) / this) from the Jinja call site","Guard with is_defined/as_object checks in the macro before calling adapter methods","Include the received value's type in the error to speed up template debugging"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}