{"record":{"id":"fdbd87347cf8fad9","repo":"clockworklabs/SpacetimeDB","slug":"unknown-return-code","errorCode":null,"errorMessage":"unknown return code","messagePattern":"unknown return code","errorType":"exception","errorClass":"ExecutionError::Recoverable","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/wasmtime/wasmtime_module.rs","lineNumber":193,"sourceCode":"\nfn handle_error_sink_code(code: i32, error: Vec<u8>) -> Result<(), ExecutionError> {\n    handle_result_sink_code(code, error).map(drop)\n}\n\npub(super) enum ViewResultSinkError {\n    User(String),\n    UnexpectedCode(i32),\n}\n\n/// Handle the return code from a function using a result sink.\n///\n/// On success, returns the result bytes.\n/// On failure, returns the error message.\nfn handle_result_sink_code(code: i32, result: Vec<u8>) -> Result<Vec<u8>, ExecutionError> {\n    match code {\n        0 => Ok(result),\n        CALL_FAILURE => Err(ExecutionError::User(string_from_utf8_lossy_owned(result).into())),\n        _ => Err(ExecutionError::Recoverable(anyhow::anyhow!(\"unknown return code\"))),\n    }\n}\n\n/// Handle the return code from a view function using a result sink.\n/// For views, we treat the return code 2 as a successful return using the header format.\nfn handle_view_result_sink_code(code: i32, result: Vec<u8>) -> Result<ViewReturnData, ExecutionError> {\n    decode_view_result_sink_code(code, result).map_err(|err| match err {\n        ViewResultSinkError::User(err) => ExecutionError::User(err.into()),\n        ViewResultSinkError::UnexpectedCode(_) => ExecutionError::Recoverable(anyhow::anyhow!(\"unknown return code\")),\n    })\n}\n\npub(super) fn decode_view_result_sink_code(code: i32, result: Vec<u8>) -> Result<ViewReturnData, ViewResultSinkError> {\n    match code {\n        0 => Ok(ViewReturnData::Rows(result.into())),\n        2 => Ok(ViewReturnData::HeaderFirst(result.into())),\n        CALL_FAILURE => Err(ViewResultSinkError::User(string_from_utf8_lossy_owned(result))),\n        _ => Err(ViewResultSinkError::UnexpectedCode(code)),","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/wasmtime/wasmtime_module.rs#L175-L211","documentation":"Error \"unknown return code\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/core/src/host/wasmtime/wasmtime_module.rs:193 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"}