clockworklabs/SpacetimeDB · error · anyhow::Error

view does not have a backing table

Error message

view {:?} does not have a backing table

What it means

resolve_view_for_refresh reads the view's row from the st_views system table and expects a materialized backing table (table_id). A None table_id means view metadata exists but the backing table was never allocated - the catalog is inconsistent, so refreshing the view cannot proceed.

Solutions

  1. Republish the module so view metadata and backing tables are rebuilt consistently.
  2. Inspect st_views/st_tables for the view id to confirm the missing allocation.
  3. Recreate the database from a known-good publish if metadata stays inconsistent.
  4. If it reproduces on a clean publish, report it as a host bug with the module attached.
Defensive patterns

Strategy: try-catch

Try / catch

Wrap view-refresh/update calls, add .context("refreshing view {id}"), and treat lookup/backing-table failures as 'republish required' rather than retryable.

Prevention

When it happens

Trigger: An interrupted or partially committed publish left an st_views row without its table; a module update path skipped table allocation for the view; system tables were edited out-of-band.

Common situations: Crash between view registration and table creation during publish; downgrading to an older host that expects table_id always set; a replica restored from an inconsistent snapshot.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20). Data as JSON: /api/errors/2448e91f856f3333. Report an issue: GitHub.

Appendix: source

Thrown at crates/core/src/host/module_host.rs:1215

    /// type-index references in the `ViewDef`.
    pub owning_def: &'a ModuleDef,
}

/// Lookup a module's [`ViewDef`] and check for consistency among
/// its readset, `st_view`, and the [`ModuleDef`].
pub(crate) fn resolve_view_for_refresh<'a>(
    tx: &MutTxId,
    module_def: &'a ModuleDef,
    view_call: &ViewCallInfo,
) -> anyhow::Result<ResolvedViewForRefresh<'a>> {
    let st_view = tx
        .lookup_st_view(view_call.view_id)
        .with_context(|| format!("failed to look up view {}", view_call.view_id))?;

    let view_id = st_view.view_id;
    let table_id = st_view
        .table_id
        .ok_or_else(|| anyhow::anyhow!("view {:?} does not have a backing table", view_id))?;

    let (global_fn_ptr, view_def, owning_def) = module_def
        .view_by_name_with_global_fn_ptr(&st_view.view_name.clone().into())
        .ok_or_else(|| {
            anyhow::anyhow!(
                "view `{}` for view id `{}` not found in current module",
                st_view.view_name,
                view_id
            )
        })?;

    let is_anonymous = view_def.is_anonymous;

    if st_view.is_anonymous != is_anonymous {
        return Err(anyhow::anyhow!(
            "found is_anonymous={} in st_view, but {} in module when updating view `{}`",
            st_view.is_anonymous,
            is_anonymous,

View on GitHub (pinned to eddf9f5014)