clockworklabs/SpacetimeDB · error · anyhow::Error
failed to typecheck args
Error message
failed to typecheck args
What it means
FunctionArgs has three shapes (Json, Bsatn, Nullary). The Nullary path skips deserialization and only asserts that the target function's parameter list is empty; if the reducer/procedure def declares parameters, that ensure! fails with 'failed to typecheck args'. At the scheduler layer the call surfaces wrapped as InvalidReducerArguments/InvalidProcedureArguments.
Solutions
- Send arguments matching the current reducer signature, as Json or Bsatn.
- Regenerate client bindings after any module signature change.
- Verify the def's params are empty before dispatching Nullary (see validation below).
- If the reducer should take no args, change the module signature to be genuinely nullary.
Example fix
// before
let p = function_to_reducer_call_params(&module, "transfer", FunctionArgs::Nullary, at)?; // failed to typecheck args
// after
let args = FunctionArgs::Json(serde_json::json!({ "from": alice, "to": bob, "amount": 10 }));
let p = function_to_reducer_call_params(&module, "transfer", args, at)?; Defensive patterns
Strategy: validation
Validate before calling
let Some((_, def, _owning)) = module.module_def.reducer_by_name_with_module(name) else {
return Err(anyhow::anyhow!("Reducer `{name}` not found"));
};
if !def.params().elements.is_empty() {
return Err(anyhow::anyhow!("`{name}` expects arguments; do not send FunctionArgs::Nullary"));
} Type guard
fn is_nullary(def: &ReducerDef) -> bool {
def.params().elements.is_empty()
} Try / catch
Catch InvalidReducerArguments/InvalidProcedureArguments where the scheduler surfaces them, and report a signature mismatch with the expected parameter list.
Prevention
- Regenerate bindings whenever the module schema changes.
- Lock server and client module versions in lockstep in CI.
- Prefer BSATN from generated types over hand-written JSON payloads.
When it happens
Trigger: Invoking a reducer that takes parameters with a nullary payload; a client built against an older module where the reducer used to take no arguments; an SDK serializing an empty argument tuple for a signature that gained fields.
Common situations: Module updated to add parameters to a lifecycle or scheduled reducer while callers still send no args; stale generated bindings; hand-rolled clients sending empty payloads that select the Nullary variant.
Related errors
- Reducer ` ` not found
- a row was a sequence trigger but there was no generated…
- Argument must be a I128
- Argument must be a I256
- Argument must be a U128
AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20).
Data as JSON: /api/errors/67149ca909b01e13.
Report an issue: GitHub.
Appendix: source
Thrown at crates/core/src/host/mod.rs:76
self._into_tuple(seed).map_err(|err| InvalidFunctionArguments {
err,
function_name: seed.name().clone().into(),
})
}
fn _into_tuple<Def: FunctionDef>(self, seed: ArgsSeed<'_, Def>) -> anyhow::Result<ArgsTuple> {
Ok(match self {
FunctionArgs::Json(json) => ArgsTuple {
tuple: from_json_seed(&json, SeedWrapper(seed))?,
bsatn: OnceCell::new(),
json: OnceCell::with_value(json),
},
FunctionArgs::Bsatn(bytes) => ArgsTuple {
tuple: seed.deserialize(bsatn::Deserializer::new(&mut &bytes[..]))?,
bsatn: OnceCell::with_value(bytes),
json: OnceCell::new(),
},
FunctionArgs::Nullary => {
anyhow::ensure!(seed.params().elements.is_empty(), "failed to typecheck args");
ArgsTuple::nullary()
}
})
}
}
#[derive(Debug, Clone)]
pub struct ArgsTuple {
tuple: ProductValue,
bsatn: OnceCell<Bytes>,
json: OnceCell<ByteString>,
}
impl ArgsTuple {
pub fn nullary() -> Self {
ArgsTuple {
tuple: spacetimedb_sats::product![],
bsatn: OnceCell::with_value(Bytes::new()),View on GitHub (pinned to eddf9f5014)