dbt-labs/dbt-core · error
this must be a BaseRelation object
Error message
this must be a BaseRelation object
What it means
The Jinja object being unwrapped exists, but the value stored under its __this__ key does not downcast to RelationObject — i.e. someone constructed a relation-like dict whose payload is not a BaseRelation wrapper, so the inner Arc<dyn BaseRelation> cannot be recovered.
Solutions
- Ensure the object stored under __this__ is a RelationObject wrapping a BaseRelation
- Avoid hand-constructing relation-like dicts; use the Relation wrapper API
- Type-check the __this__ payload before downcasting
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/dbt-adapter/src/cast_util.rs:29 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/b5e1c004b3012283.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-adapter/src/cast_util.rs:29
pub fn downcast_value_to_dyn_base_relation(
value: &minijinja::Value,
) -> Result<Arc<dyn BaseRelation>, minijinja::Error> {
if let Some(relation_object) = value.downcast_object::<RelationObject>() {
Ok(relation_object.inner())
} else if let Some(relation_object) = value
.as_object()
.ok_or_else(|| {
minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
"relation must be an object",
)
})?
.get_value(&minijinja::Value::from(THIS_RELATION_KEY))
{
Ok(relation_object
.downcast_object::<RelationObject>()
.ok_or_else(|| {
minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
"this must be a BaseRelation object",
)
})?
.inner())
} else {
Err(minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
format!(
"Unsupported relation type ({}) in {}:{}",
value,
file!(),
line!()
),
))
}
}
View on GitHub (pinned to 0267ce9170)