{"record":{"id":"5932a1039d259ed6","repo":"clockworklabs/SpacetimeDB","slug":"view-does-not-have-a-backing-table-in-database","errorCode":null,"errorMessage":"view {} does not have a backing table in database","messagePattern":"view (.+?) does not have a backing table in database","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/wasm_common/module_host_actor.rs","lineNumber":1651,"sourceCode":"            ..\n        } = view;\n\n        // Full namespaced canonical name: matches both the st_view registration\n        // (create_view / create_view_with_prefix) and `view_by_name_with_global_fn_ptr`.\n        let view_name = prefix.join(local_name.clone());\n\n        let (global_fn_ptr, _, _) = module_def\n            .view_by_name_with_global_fn_ptr(&view_name)\n            .ok_or_else(|| anyhow::anyhow!(\"view {} not found in module_def\", view_name))?;\n\n        let st_view = tx\n            .view_from_name(&view_name)?\n            .ok_or_else(|| anyhow::anyhow!(\"view {} not found in database\", view_name))?;\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 in database\", view_name))?;\n        let subs = tx.materialized_view_instances_for_view(view_id);\n        let view_typespace = Arc::new(owning_def.typespace().clone());\n\n        if *is_anonymous {\n            if subs.is_empty() {\n                continue;\n            }\n            view_calls.push(CallViewParams {\n                view_name: view_name.clone(),\n                view_id,\n                table_id,\n                fn_ptr: global_fn_ptr,\n                caller: owner_identity,\n                sender: None,\n                args: ArgsTuple::nullary(),\n                row_type: *product_type_ref,\n                timestamp: Timestamp::now(),\n                view_typespace: view_typespace.clone(),","sourceCodeStart":1633,"sourceCodeEnd":1669,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/host/wasm_common/module_host_actor.rs#L1633-L1669","documentation":"The st_view row for the view exists but its table_id column is NULL, so there is no backing table to write materialized rows into. collect_subscribed_view_calls needs table_id to construct the refresh call, so view refresh aborts. A view row without a backing table means view creation was interrupted or the metadata was written in a partially initialized state.","triggerScenarios":"A publish or create_view that failed between inserting the st_view row and allocating its backing table; concurrent publishes racing on the same view name; direct manipulation of st_view rows.","commonSituations":"Interrupted spacetime publish (Ctrl-C, node restart mid-publish); older server versions with non-atomic view creation.","solutions":["Republish the module so view creation runs again and assigns the backing table","If it persists, change the view set (or drop/recreate the view) to force clean metadata, then republish","Check server logs for a failed or interrupted publish around the time the view was created"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure each registered view has a backing table before mutations\nfor name in module_view_names {\n    if let Some(st_view) = tx.view_from_name(&name).ok().flatten() {\n        if st_view.table_id.is_none() {\n            return Err(anyhow::anyhow!(\"view {name} lacks a backing table; republish to repair\"));\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"match dml_result {\n    Err(e) if e.to_string().contains(\"does not have a backing table\") => {\n        // Republish the module to rebuild view metadata, then retry\n    }\n    other => other,\n}","preventionTips":["Let publishes finish; avoid killing the server mid-publish","After any interrupted publish, republish before accepting traffic","Monitor st_view.table_id for NULLs as a health check"],"tags":["spacetimedb","views","database-metadata","partial-publish"],"backgroundTag":"view-missing-backing-table","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"}