{"record":{"id":"2448e91f856f3333","repo":"clockworklabs/SpacetimeDB","slug":"view-does-not-have-a-backing-table","errorCode":null,"errorMessage":"view {:?} does not have a backing table","messagePattern":"view (.+?) does not have a backing table","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/module_host.rs","lineNumber":1215,"sourceCode":"    /// type-index references in the `ViewDef`.\n    pub owning_def: &'a ModuleDef,\n}\n\n/// Lookup a module's [`ViewDef`] and check for consistency among\n/// its readset, `st_view`, and the [`ModuleDef`].\npub(crate) fn resolve_view_for_refresh<'a>(\n    tx: &MutTxId,\n    module_def: &'a ModuleDef,\n    view_call: &ViewCallInfo,\n) -> anyhow::Result<ResolvedViewForRefresh<'a>> {\n    let st_view = tx\n        .lookup_st_view(view_call.view_id)\n        .with_context(|| format!(\"failed to look up view {}\", view_call.view_id))?;\n\n    let view_id = st_view.view_id;\n    let table_id = st_view\n        .table_id\n        .ok_or_else(|| anyhow::anyhow!(\"view {:?} does not have a backing table\", view_id))?;\n\n    let (global_fn_ptr, view_def, owning_def) = module_def\n        .view_by_name_with_global_fn_ptr(&st_view.view_name.clone().into())\n        .ok_or_else(|| {\n            anyhow::anyhow!(\n                \"view `{}` for view id `{}` not found in current module\",\n                st_view.view_name,\n                view_id\n            )\n        })?;\n\n    let is_anonymous = view_def.is_anonymous;\n\n    if st_view.is_anonymous != is_anonymous {\n        return Err(anyhow::anyhow!(\n            \"found is_anonymous={} in st_view, but {} in module when updating view `{}`\",\n            st_view.is_anonymous,\n            is_anonymous,","sourceCodeStart":1197,"sourceCodeEnd":1233,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/host/module_host.rs#L1197-L1233","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Republish the module so view metadata and backing tables are rebuilt consistently.","Inspect st_views/st_tables for the view id to confirm the missing allocation.","Recreate the database from a known-good publish if metadata stays inconsistent.","If it reproduces on a clean publish, report it as a host bug with the module attached."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Wrap view-refresh/update calls, add .context(\"refreshing view {id}\"), and treat lookup/backing-table failures as 'republish required' rather than retryable.","preventionTips":["Never hand-edit system tables (st_*) in production databases.","Let publish/update be the only writer of view metadata.","Back up before host version downgrades."],"tags":["view","system-table","metadata","refresh","internal"],"backgroundTag":"schema-metadata-inconsistent","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}