{"record":{"id":"9a0b9c19a34eb302","repo":"clockworklabs/SpacetimeDB","slug":"unable-to-encode-view-return-value","errorCode":null,"errorMessage":"unable to encode view return value","messagePattern":"unable to encode view return value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings/src/rt.rs","lineNumber":98,"sourceCode":"    note = \"where each `Ti` type implements `SpacetimeType`.\",\n    note = \"\"\n)]\npub trait Reducer<'de, A: Args<'de>> {\n    fn invoke(&self, ctx: &ReducerContext, args: A) -> ReducerResult;\n}\n\n/// Invoke a caller-specific view.\n/// Returns a BSATN encoded `Vec` of rows.\npub fn invoke_view<'a, A: Args<'a>, T: ViewReturn>(\n    view: impl View<'a, A, T>,\n    ctx: ViewContext,\n    args: &'a [u8],\n) -> Vec<u8> {\n    // Deserialize the arguments from a bsatn encoding.\n    let SerDeArgs(args) = bsatn::from_slice(args).expect(\"unable to decode args\");\n    let retn = view.invoke(&ctx, args);\n    let mut buf = IterBuf::take();\n    retn.to_writer(&mut buf).expect(\"unable to encode view return value\");\n    std::mem::take(&mut *buf)\n}\n/// A trait for types representing the execution logic of a caller-specific view.\n#[expect(clippy::duplicated_attributes, reason = \"false positive\")]\n#[diagnostic::on_unimplemented(\n    message = \"invalid view signature\",\n    label = \"this view signature is not valid\",\n    note = \"\",\n    note = \"view signatures must match:\",\n    note = \"    `Fn(&ViewContext, [T1, ...]) -> Vec<Tn> | Option<Tn>`\",\n    note = \"where each `Ti` implements `SpacetimeType`.\",\n    note = \"\"\n)]\npub trait View<'de, A: Args<'de>, T: ViewReturn> {\n    fn invoke(&self, ctx: &ViewContext, args: A) -> T;\n}\n\n/// Invoke an anonymous view.","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings/src/rt.rs#L80-L116","documentation":"Error \"unable to encode view return value\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/bindings/src/rt.rs:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}