{"record":{"id":"58f7f4ae756c0c05","repo":"clockworklabs/SpacetimeDB","slug":"error-resolving-row-type-for-view","errorCode":null,"errorMessage":"Error resolving row type for view","messagePattern":"Error resolving row type for view","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/src/host/wasm_common/module_host_actor.rs","lineNumber":1375,"sourceCode":"            }\n            // TODO: maybe do something else with user errors?\n            (Err(ExecutionError::User(err)), _) => {\n                inst.log_traceback(\"view\", &view_name, &anyhow::anyhow!(err));\n                self.handle_outer_error(&result.stats.energy, &view_name).into()\n            }\n            (Ok(raw), sender) => {\n                // This is wrapped in a closure to simplify error handling.\n                let outcome: Result<ViewOutcome, anyhow::Error> = (|| {\n                    let view_call = match sender {\n                        Some(sender) => ViewCallInfo::sender(view_id, sender),\n                        None => ViewCallInfo::anonymous(view_id),\n                    };\n                    let result = ViewResult::from_return_data(raw).context(\"Error parsing view result\")?;\n                    let row_product_type = view_typespace\n                        .resolve(row_type)\n                        .resolve_refs()?\n                        .into_product()\n                        .map_err(|_| anyhow!(\"Error resolving row type for view\"))?;\n\n                    let rows = match result {\n                        ViewResult::Rows(bytes) => deserialize_view_rows(row_type, bytes, &view_typespace)\n                            .context(\"Error deserializing rows returned by view\".to_string())?,\n                        ViewResult::RawSql(query) => self\n                            .run_query_for_view(&mut tx, &query, &row_product_type, &view_call)\n                            .context(\"Error executing raw SQL returned by view\".to_string())?,\n                    };\n\n                    let replica_ctx = inst.replica_ctx();\n                    let stdb = replica_ctx.relational_db();\n                    stdb.materialize_view_call(&mut tx, table_id, view_call, rows)\n                        .context(\"Error materializing view\")?;\n\n                    Ok(ViewOutcome::Success)\n                })();\n                match outcome {\n                    Ok(outcome) => outcome,","sourceCodeStart":1357,"sourceCodeEnd":1393,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/wasm_common/module_host_actor.rs#L1357-L1393","documentation":"After a view returns data during (re)evaluation, the host resolves the view's row type in the owning module's typespace via resolve(product_type_ref).resolve_refs().into_product(). If the reference cannot be resolved, refs remain unresolved, or the result is not a product (row) type, this generic error is raised. It means the module's type definitions and the view registration disagree.","triggerScenarios":"The view's product_type_ref does not resolve in the typespace it is resolved against: module rebuilt with a different SDK producing a different typespace layout, stale view registrations from an older module generation, or a corrupted module description.","commonSituations":"Version skew between the module build that registered the views and the current module_def; republishing after SDK upgrades that reorder type definitions; views moved between submodules so the owning typespace no longer contains the row type.","solutions":["Rebuild and republish the module with the SDK version matching the host so typespace and view registrations come from one build.","If the database carries stale view registrations, clear them (or recreate the database if the data is disposable) and republish.","Verify via module introspection that each view's row type resolves in its owning module's typespace.","If it reproduces on a clean publish, report it with the module artifact."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// after build, verify every view's row type resolves in its owning typespace\nfor v in module_def.views() {\n    let ty = owning_typespace.resolve(v.product_type_ref)?.resolve_refs()?;\n    ty.into_product()?; // must be a product (row) type\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rebuild and republish with matching SDK and host versions after any upgrade.","Do not move views between modules without a clean republish.","Treat typespace-resolution failures as build artifacts to regenerate, not data to patch."],"tags":["views","typespace","type-resolution","module-def"],"backgroundTag":"type-resolution-failed","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}