{"record":{"id":"ec97085462622e41","repo":"dbt-labs/dbt-core","slug":"remote-state-must-be-object","errorCode":null,"errorMessage":"remote_state must be Object","messagePattern":"remote_state must be Object","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/relation/relation_impl.rs","lineNumber":1284,"sourceCode":"                    RedshiftMaterializedViewConfigChangeset::new(remote_state, local_config);\n\n                if changeset.has_changes() {\n                    Ok(Value::from_object(changeset))\n                } else {\n                    Ok(Value::from(None::<()>))\n                }\n            }\n            Bigquery => {\n                if remote_state_value.is_none() {\n                    return Err(minijinja::Error::new(\n                        minijinja::ErrorKind::InvalidArgument,\n                        \"remote_state cannot be None\",\n                    ));\n                }\n                let current_state = remote_state_value\n                    .as_object()\n                    .ok_or_else(|| {\n                        minijinja::Error::new(\n                            minijinja::ErrorKind::InvalidArgument,\n                            \"remote_state must be Object\",\n                        )\n                    })?\n                    .downcast_ref::<RelationConfig>()\n                    .ok_or_else(|| {\n                        minijinja::Error::new(\n                            minijinja::ErrorKind::InvalidArgument,\n                            \"remote_state must be RelationConfig\",\n                        )\n                    })?;\n\n                // TODO(serramatutu): minijinja_value_to_typed_struct does not work with\n                // references, so we have to clone the value here...\n                let local_config = minijinja_value_to_typed_struct::<InternalDbtNodeWrapper>(\n                    local_config_value.clone(),\n                )\n                .map_err(|e| {","sourceCodeStart":1266,"sourceCodeEnd":1302,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/relation/relation_impl.rs#L1266-L1302","documentation":"After the None check, the BigQuery branch calls `as_object()` on remote_state_value and errors if it is not a minijinja object. The state must be an object that can be downcast to a RelationConfig; anything else (string, number, array, plain dict of the wrong shape) produces this InvalidArgument error.","triggerScenarios":"Passing a remote_state that is not a RelationConfig object — e.g. a primitive, list, or an unrelated object type — to the BigQuery changeset call.","commonSituations":"Hand-built remote state dicts in macros, passing the describe results object of a different adapter, or serialization round-trips that convert the RelationConfig into a plain value.","solutions":["Pass the RelationConfig object returned by the adapter's remote-state/describe API rather than a raw dict.","If constructing state manually, build a RelationConfig via the adapter's relation helpers so downcast succeeds.","Ensure you are not crossing adapter boundaries (BigQuery state must come from BigQuery describe results)."],"exampleFix":"// before\nrelation.changeset(remote_state={'columns': cols})\n// after\nrelation.changeset(remote_state=remote_state)  # RelationConfig object from adapter","handlingStrategy":"type-guard","validationCode":"{% if remote_state is not mapping %}\n  {{ exceptions.raise_compiler_error('remote_state must be a RelationConfig object') }}\n{% endif %}","typeGuard":"fn is_relation_config(v: &Value) -> bool {\n    v.as_object()\n        .and_then(|o| o.downcast_ref::<RelationConfig>())\n        .is_some()\n}","tryCatchPattern":"let cfg = remote_state_value.as_object()\n    .and_then(|o| o.downcast_ref::<RelationConfig>())\n    .ok_or_else(|| warn_and_refetch(relation))?;","preventionTips":["Pass RelationConfig objects, never plain dicts or primitives","Do not mix remote state across adapters","Avoid serializing/deserializing state in ways that lose the object type"],"tags":["bigquery","type-mismatch","jinja","argument"],"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"}