clockworklabs/SpacetimeDB · error · anyhow::Error
data key not found in return object
Error message
data key not found in return object
What it means
In the v1 syscall path for __call_view_anon__, a view may return raw bytes (legacy) or an object whose `data` field holds a Uint8Array. This branch handles the object form: ret.get(scope, 'data') returned None, so the returned object lacks the required `data` property and the result bytes cannot be extracted.
Solutions
- Rebuild and republish the module with the SDK version matching the host.
- Never hand-write __call_view_anon__ return values; use SDK-generated bindings.
- Upgrade host and module together in lockstep.
- If both are current, report the ABI mismatch with module and host versions.
Defensive patterns
Strategy: validation
Try / catch
Catch view-call errors containing 'data key not found' and surface them as 'module/host ABI mismatch - republish the module with a matching SDK' rather than as app-level view errors.
Prevention
- Pin module SDK and host versions together in CI.
- Never bypass generated bindings for view functions.
- Run a canary view call after every publish.
When it happens
Trigger: A v1 module's view function returns an arbitrary JS object without `data`; SDK/host version skew changed the expected return shape; hand-implemented view bindings returning the wrong structure.
Common situations: Upgrading the module SDK or the host independently; copying view implementations across ABI versions; partially migrated codebases.
Related errors
- data key not found in return object
- AddView: view ` ` not found in new module def
- export is a function with incorrect type
- export is a function with incorrect type
- export is a function with incorrect type
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/65ecc410c98ebaa3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/core/src/host/v8/syscall/v1.rs:562
// The original version returned a byte array with the encoded rows.
if ret.is_typed_array() && ret.is_uint8_array() {
// This is the original format, which just returns the raw bytes.
let ret =
cast!(scope, ret, v8::Uint8Array, "bytes return from `__call_view_anon__`").map_err(|e| e.throw(scope))?;
let bytes = ret.get_contents(&mut []);
return Ok(ViewReturnData::Rows(Bytes::copy_from_slice(bytes)));
};
// The newer version returns an object with a `data` field containing the bytes.
let ret = cast!(scope, ret, v8::Object, "object return from `__call_view_anon__`").map_err(|e| e.throw(scope))?;
let Some(data_key) = v8::String::new(scope, "data") else {
return Err(ErrorOrException::Err(anyhow::anyhow!("error creating a v8 string")));
};
let Some(data_val) = ret.get(scope, data_key.into()) else {
return Err(ErrorOrException::Err(anyhow::anyhow!(
"data key not found in return object"
)));
};
let ret = cast!(
scope,
data_val,
v8::Uint8Array,
"bytes in the `data` field returned from `__call_view_anon__`"
)
.map_err(|e| e.throw(scope))?;
let bytes = ret.get_contents(&mut []);
Ok(ViewReturnData::HeaderFirst(Bytes::copy_from_slice(bytes)))
}
/// Calls the `__call_view_anon__` function `fun`.
pub(super) fn call_call_view_anon(View on GitHub (pinned to 6dee26c6ef)