{"record":{"id":"80b4931d5a4894ed","repo":"clockworklabs/SpacetimeDB","slug":"view-for-view-id-not-found-in-current-mo","errorCode":null,"errorMessage":"view `{}` for view id `{}` not found in current module","messagePattern":"view `(.+?)` for view id `(.+?)` not found in current module","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/src/host/module_host.rs","lineNumber":1182,"sourceCode":"/// 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,\n            st_view.view_name,\n        ));\n    }\n\n    Ok(ResolvedViewForRefresh {","sourceCodeStart":1164,"sourceCodeEnd":1200,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/module_host.rs#L1164-L1200","documentation":"The view-refresh path found the view's id in the st_views catalog, but the currently loaded module definition has no view with that catalogued name, so the definitions cannot be matched. On-disk schema state and the loaded module disagree — typically leftover catalog rows after a module update renamed or removed a view.","triggerScenarios":"A module update drops or renames a view while a refresh for the old view id is still being processed; a publish interrupted between the catalog write and the module swap; replaying view refreshes against a module whose view set changed.","commonSituations":"Renaming or removing views between publishes; subscriptions/refreshes active during update; rolling back to an older module with different view names.","solutions":["Re-publish the current module so catalog and module stay consistent.","If the state is stale and data is disposable, delete and recreate the database.","Avoid renaming or dropping views while subscriptions to them are live; make view renames two-step (add new, remove old) across publishes.","Report with logs if it occurs without any schema changes on your side."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await refreshViews(db);\n} catch (e) {\n  if (String(e).includes('not found in current module')) {\n    await spacetimePublish(dbName, modulePath); // catalog/module drift: re-converge via publish\n    return refreshViews(db);\n  }\n  throw e;\n}","preventionTips":["Publish schema changes while subscriptions to affected views are idle.","Avoid renaming views in one step; add the new name first, migrate, then remove the old.","Verify publishes complete successfully before rotating clients to the new module."],"tags":["spacetimedb","views","schema-drift","module-update","catalog"],"backgroundTag":"schema-drift","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}