{"record":{"id":"6c7a52e773e3b00c","repo":"clockworklabs/SpacetimeDB","slug":"error-resolving-row-type-for-view-6c7a52","errorCode":null,"errorMessage":"Error resolving row type for view","messagePattern":"Error resolving row type for view","errorType":"exception","errorClass":"WasmError","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/wasmtime/wasm_instance_env.rs","lineNumber":1804,"sourceCode":"                            \"failed to look up materialized view args for view {}\",\n                            view_call.view_id\n                        )\n                    })?\n                    .sender();\n\n                let current_tx = tx.take().expect(\"procedure tx missing during view refresh\");\n                let (next_tx, call_result) = tx_slot.set(current_tx, || {\n                    Self::call_view(caller, &view_call, view_name, fn_ptr, sender)\n                });\n                tx = Some(next_tx);\n                let return_data = call_result?;\n\n                let typespace = resolved.owning_def.typespace();\n                let row_product_type = typespace\n                    .resolve(view_def.product_type_ref)\n                    .resolve_refs()?\n                    .into_product()\n                    .map_err(|_| anyhow!(\"Error resolving row type for view\"))?;\n\n                let rows = match ViewResult::from_return_data(return_data)? {\n                    ViewResult::Rows(bytes) => deserialize_view_rows(view_def.product_type_ref, bytes, typespace)\n                        .map_err(|err| anyhow!(err.to_string()))?,\n                    ViewResult::RawSql(query) => run_query_for_view(\n                        tx.as_mut().expect(\"procedure tx missing while running view query\"),\n                        &query,\n                        &row_product_type,\n                        &view_call,\n                        *caller.data().instance_env.database_identity(),\n                    )?,\n                };\n\n                let stdb = caller.data().instance_env.relational_db().clone();\n                stdb.materialize_view_call(\n                    tx.as_mut()\n                        .expect(\"procedure tx missing while materializing refreshed view\"),\n                    table_id,","sourceCodeStart":1786,"sourceCodeEnd":1822,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/wasmtime/wasm_instance_env.rs#L1786-L1822","documentation":"The wasmtime-side twin of the module_host_actor check: after a view call returns during refresh, the view's product_type_ref is resolved against the owning module's typespace and converted into a product type. Failure means the reference does not resolve to a row/product type in that typespace — the module's type definitions and the view definition disagree.","triggerScenarios":"product_type_ref points at a type that is not in the resolved typespace or is not a product: a module built against a different SDK/typespace than the one that recorded the view definition, stale view metadata after upgrades, or corrupted module artifacts.","commonSituations":"SDK/host version skew across republishes; moving views between modules or submodules; partial upgrades leaving old view metadata in place.","solutions":["Rebuild and republish with SDK and host versions in lockstep so view metadata and typespace come from the same build.","Clear stale view state (drop the views or recreate the database if 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 build, report it with the module artifact."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify the view row type resolves in the owning module's typespace before refresh\nlet ty = owning_def.typespace().resolve(view_def.product_type_ref)?.resolve_refs()?;\nty.into_product()?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rebuild and republish with matching SDK and host versions after upgrades.","Do not move views between modules or submodules without a clean republish.","Treat type-resolution failures as stale metadata to regenerate."],"tags":["views","typespace","type-resolution","wasmtime"],"backgroundTag":"type-resolution-failed","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}