dbt-labs/dbt-core · error

remote_state cannot be None

Error message

remote_state cannot be None

What it means

In the BigQuery branch of the changeset code, `remote_state_value` must be present; if it is None the code raises this InvalidArgument error instead of proceeding. The BigQuery path has no way to compute a changeset without the current remote state of the table/view.

Source

Thrown at crates/dbt-adapter/src/relation/relation_impl.rs:1276

                                "materialized_view_config_changeset: Failed to deserialize RedshiftMaterializedViewConfig: {e}"
                            ),
                        )
                    })?;

                let local_config = node_value_to_redshift_materialized_view(local_config_value)?;

                let changeset =
                    RedshiftMaterializedViewConfigChangeset::new(remote_state, local_config);

                if changeset.has_changes() {
                    Ok(Value::from_object(changeset))
                } else {
                    Ok(Value::from(None::<()>))
                }
            }
            Bigquery => {
                if remote_state_value.is_none() {
                    return Err(minijinja::Error::new(
                        minijinja::ErrorKind::InvalidArgument,
                        "remote_state cannot be None",
                    ));
                }
                let current_state = remote_state_value
                    .as_object()
                    .ok_or_else(|| {
                        minijinja::Error::new(
                            minijinja::ErrorKind::InvalidArgument,
                            "remote_state must be Object",
                        )
                    })?
                    .downcast_ref::<RelationConfig>()
                    .ok_or_else(|| {
                        minijinja::Error::new(
                            minijinja::ErrorKind::InvalidArgument,
                            "remote_state must be RelationConfig",
                        )

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Fetch and pass the remote state (e.g. results of describing the BigQuery table/view) before computing the changeset.
  2. Handle upstream describe failures so None never propagates into this call.
  3. Skip changeset computation for create-on-first-run cases instead of passing None.

Example fix

-- before
{{ relation.changeset(remote_state=None) }}
-- after
{% set results = api.Relation.get_remote_state(relation) %}
{{ relation.changeset(remote_state=results) }}
Defensive patterns

Strategy: validation

Validate before calling

{% if remote_state is none %}
  {{ exceptions.raise_compiler_error('BigQuery changeset requires remote_state; fetch it first') }}
{% endif %}

Type guard

let has_state = remote_state_value.is_some();

Try / catch

try:
    changeset = relation.changeset(remote_state=remote_state)
except minijinja.Error as e:
    if 'remote_state cannot be None' in str(e):
        remote_state = fetch_remote_state(relation)
        changeset = relation.changeset(remote_state=remote_state)
    else:
        raise

Prevention

When it happens

Trigger: Calling the changeset function for a BigQuery relation with remote_state=None (e.g. describe results were not fetched or were discarded).

Common situations: Macros skipping the remote-state fetch on error, first-run flows passing nothing as state, or code paths that default state to None.

Related errors


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/b3fdcce0e073f4d2. Report an issue: GitHub.