clockworklabs/SpacetimeDB · error · anyhow::Error
view ` ` for view id ` ` not found in current module
Error message
view `{}` for view id `{}` not found in current module What it means
The st_views row for a view id stores the view name, and the host resolves that name against the currently loaded ModuleDef via view_by_name_with_global_fn_ptr. A miss means stored metadata and the running module disagree - usually because the module changed (renamed/removed views) while stale st_views rows remain.
Solutions
- Republish or fully re-run the module update so metadata matches the program.
- Avoid renaming/removing views in place: add the new view, migrate, then remove the old one.
- Restart the host process to reload the module if the program on disk is correct but stale in memory.
- Report with the module if a clean republish still mismatches.
Defensive patterns
Strategy: try-catch
Try / catch
Catch during view refresh and distinguish 'not found in current module' from 'failed to look up view': the former calls for republish, the latter for catalog investigation.
Prevention
- Treat view names as stable public API; deprecate instead of rename.
- Run updates in a maintenance window with view traffic paused.
- Verify st_views names against the new module definition in staging before production updates.
When it happens
Trigger: A module update renamed or deleted a view while a refresh was already scheduled for the old view id; a concurrent publish racing a view call; submodule layout changed so the name no longer resolves.
Common situations: Deploying a schema refactor across versions; a crashed update leaving half-old metadata; clients holding view ids from an older program.
Related errors
- found is_anonymous= in st_view, but in module when updating…
- view does not have a backing table
- View ' ' can have at most one primaryKey() column on its…
- AddView: view ` ` not found in new module def
- Cannot define RLS rule on private table
AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20).
Data as JSON: /api/errors/80b4931d5a4894ed.
Report an issue: GitHub.
Appendix: source
Thrown at crates/core/src/host/module_host.rs:1220
/// its readset, `st_view`, and the [`ModuleDef`].
pub(crate) fn resolve_view_for_refresh<'a>(
tx: &MutTxId,
module_def: &'a ModuleDef,
view_call: &ViewCallInfo,
) -> anyhow::Result<ResolvedViewForRefresh<'a>> {
let st_view = tx
.lookup_st_view(view_call.view_id)
.with_context(|| format!("failed to look up view {}", view_call.view_id))?;
let view_id = st_view.view_id;
let table_id = st_view
.table_id
.ok_or_else(|| anyhow::anyhow!("view {:?} does not have a backing table", view_id))?;
let (global_fn_ptr, view_def, owning_def) = module_def
.view_by_name_with_global_fn_ptr(&st_view.view_name.clone().into())
.ok_or_else(|| {
anyhow::anyhow!(
"view `{}` for view id `{}` not found in current module",
st_view.view_name,
view_id
)
})?;
let is_anonymous = view_def.is_anonymous;
if st_view.is_anonymous != is_anonymous {
return Err(anyhow::anyhow!(
"found is_anonymous={} in st_view, but {} in module when updating view `{}`",
st_view.is_anonymous,
is_anonymous,
st_view.view_name,
));
}
Ok(ResolvedViewForRefresh {View on GitHub (pinned to eddf9f5014)