{"record":{"id":"6ce0291de13bca44","repo":"clockworklabs/SpacetimeDB","slug":"view-not-found-in-module-def","errorCode":null,"errorMessage":"view {} not found in module_def","messagePattern":"view (.+?) not found in module_def","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/src/host/wasm_common/module_host_actor.rs","lineNumber":1530,"sourceCode":"    owner_identity: Identity,\n) -> Result<Vec<CallViewParams>, anyhow::Error> {\n    let mut view_calls = Vec::new();\n\n    for (prefix, owning_def, view) in module_def.all_views_with_prefix() {\n        let ViewDef {\n            name: local_name,\n            is_anonymous,\n            product_type_ref,\n            ..\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(),","sourceCodeStart":1512,"sourceCodeEnd":1548,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/wasm_common/module_host_actor.rs#L1512-L1548","documentation":"When (re)initializing views during publish/update, the host computes each view's full namespaced canonical name (prefix joined with the local name, matching how create_view registered it) and looks it up in module_def via view_by_name_with_global_fn_ptr. A miss means the database expects a view the current module does not define under that exact name. Because the name includes the namespace prefix, moving a view between submodules changes it.","triggerScenarios":"Renaming or moving a view between publishes so an old st_view registration survives under the previous name; publishing a module revision that dropped a view still registered in the database; submodule reorganization changing the prefixed canonical name.","commonSituations":"Iterative development where views are renamed or deleted across publishes; cleanups that update module code but not the database's view catalog; multi-module layouts with changing namespaces.","solutions":["Check the deployed module's view list and make the canonical name (including namespace prefix) match on both sides.","If the view was renamed intentionally, remove the stale registration (drop the view, or recreate the database if disposable) and republish.","Republish the module that defines the view under the name the database expects.","After renames, verify the view catalog is consistent before relying on materialized state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before publish: canonical view names must exist in both module and database catalog\nlet module_views: HashSet<_> = module_def.view_names().collect();\nlet db_views: HashSet<_> = tx.view_names()?;\nfor name in module_views.symmetric_difference(&db_views) {\n    anyhow::bail!(\"view catalog mismatch: {name}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid renaming or moving views between publishes; if unavoidable, drop old registrations in the same release.","Remember the canonical name includes the submodule namespace prefix.","Re-verify the view catalog after every publish that touches views."],"tags":["views","view-registration","name-resolution","publish"],"backgroundTag":"view-not-found","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}