{"record":{"id":"67149ca909b01e13","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-typecheck-args","errorCode":null,"errorMessage":"failed to typecheck args","messagePattern":"failed to typecheck args","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/mod.rs","lineNumber":76,"sourceCode":"        self._into_tuple(seed).map_err(|err| InvalidFunctionArguments {\n            err,\n            function_name: seed.name().clone().into(),\n        })\n    }\n    fn _into_tuple<Def: FunctionDef>(self, seed: ArgsSeed<'_, Def>) -> anyhow::Result<ArgsTuple> {\n        Ok(match self {\n            FunctionArgs::Json(json) => ArgsTuple {\n                tuple: from_json_seed(&json, SeedWrapper(seed))?,\n                bsatn: OnceCell::new(),\n                json: OnceCell::with_value(json),\n            },\n            FunctionArgs::Bsatn(bytes) => ArgsTuple {\n                tuple: seed.deserialize(bsatn::Deserializer::new(&mut &bytes[..]))?,\n                bsatn: OnceCell::with_value(bytes),\n                json: OnceCell::new(),\n            },\n            FunctionArgs::Nullary => {\n                anyhow::ensure!(seed.params().elements.is_empty(), \"failed to typecheck args\");\n                ArgsTuple::nullary()\n            }\n        })\n    }\n}\n\n#[derive(Debug, Clone)]\npub struct ArgsTuple {\n    tuple: ProductValue,\n    bsatn: OnceCell<Bytes>,\n    json: OnceCell<ByteString>,\n}\n\nimpl ArgsTuple {\n    pub fn nullary() -> Self {\n        ArgsTuple {\n            tuple: spacetimedb_sats::product![],\n            bsatn: OnceCell::with_value(Bytes::new()),","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/host/mod.rs#L58-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet p = function_to_reducer_call_params(&module, \"transfer\", FunctionArgs::Nullary, at)?; // failed to typecheck args\n\n// after\nlet args = FunctionArgs::Json(serde_json::json!({ \"from\": alice, \"to\": bob, \"amount\": 10 }));\nlet p = function_to_reducer_call_params(&module, \"transfer\", args, at)?;","handlingStrategy":"validation","validationCode":"let Some((_, def, _owning)) = module.module_def.reducer_by_name_with_module(name) else {\n    return Err(anyhow::anyhow!(\"Reducer `{name}` not found\"));\n};\nif !def.params().elements.is_empty() {\n    return Err(anyhow::anyhow!(\"`{name}` expects arguments; do not send FunctionArgs::Nullary\"));\n}","typeGuard":"fn is_nullary(def: &ReducerDef) -> bool {\n    def.params().elements.is_empty()\n}","tryCatchPattern":"Catch InvalidReducerArguments/InvalidProcedureArguments where the scheduler surfaces them, and report a signature mismatch with the expected parameter list.","preventionTips":["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."],"tags":["reducer","arguments","typecheck","bsatn","scheduler"],"backgroundTag":"invalid-function-arguments","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}