clockworklabs/SpacetimeDB · error

Error resolving row type for view

Error message

Error resolving row type for view

What it means

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.

Source

Thrown at crates/core/src/host/wasm_common/module_host_actor.rs:1375

            }
            // TODO: maybe do something else with user errors?
            (Err(ExecutionError::User(err)), _) => {
                inst.log_traceback("view", &view_name, &anyhow::anyhow!(err));
                self.handle_outer_error(&result.stats.energy, &view_name).into()
            }
            (Ok(raw), sender) => {
                // This is wrapped in a closure to simplify error handling.
                let outcome: Result<ViewOutcome, anyhow::Error> = (|| {
                    let view_call = match sender {
                        Some(sender) => ViewCallInfo::sender(view_id, sender),
                        None => ViewCallInfo::anonymous(view_id),
                    };
                    let result = ViewResult::from_return_data(raw).context("Error parsing view result")?;
                    let row_product_type = view_typespace
                        .resolve(row_type)
                        .resolve_refs()?
                        .into_product()
                        .map_err(|_| anyhow!("Error resolving row type for view"))?;

                    let rows = match result {
                        ViewResult::Rows(bytes) => deserialize_view_rows(row_type, bytes, &view_typespace)
                            .context("Error deserializing rows returned by view".to_string())?,
                        ViewResult::RawSql(query) => self
                            .run_query_for_view(&mut tx, &query, &row_product_type, &view_call)
                            .context("Error executing raw SQL returned by view".to_string())?,
                    };

                    let replica_ctx = inst.replica_ctx();
                    let stdb = replica_ctx.relational_db();
                    stdb.materialize_view_call(&mut tx, table_id, view_call, rows)
                        .context("Error materializing view")?;

                    Ok(ViewOutcome::Success)
                })();
                match outcome {
                    Ok(outcome) => outcome,

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Rebuild and republish the module with the SDK version matching the host so typespace and view registrations come from one build.
  2. If the database carries stale view registrations, clear them (or recreate the database if the data is disposable) and republish.
  3. Verify via module introspection that each view's row type resolves in its owning module's typespace.
  4. If it reproduces on a clean publish, report it with the module artifact.
Defensive patterns

Strategy: validation

Validate before calling

// after build, verify every view's row type resolves in its owning typespace
for v in module_def.views() {
    let ty = owning_typespace.resolve(v.product_type_ref)?.resolve_refs()?;
    ty.into_product()?; // must be a product (row) type
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/58f7f4ae756c0c05. Report an issue: GitHub.