{"record":{"id":"a349577e5987a227","repo":"cube-js/cube","slug":"return-type-should-be","errorCode":null,"errorMessage":"Return type should be {}","messagePattern":"Return type should be (.+?)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"rust/cube/cubesqlplanner/nativebridge/src/lib.rs","lineNumber":232,"sourceCode":"                }\n            }\n        }\n        Ok(method_params)\n    }\n    fn get_output_for_deserializer(\n        tp: &ReturnType,\n        optional: bool,\n        vec: bool,\n    ) -> syn::Result<NativeOutputParams> {\n        let mut expected_type = \"Result<_>\".to_string();\n        if optional {\n            expected_type = expected_type.replace(\"_\", \"Option<_>\");\n        }\n        if vec {\n            expected_type = expected_type.replace(\"_\", \"Vec<_>\");\n        }\n        let s = match tp {\n            ReturnType::Default => Err(syn::Error::new(\n                tp.span(),\n                format!(\"Return type should be {}\", expected_type),\n            )),\n            ReturnType::Type(_, tt) => match tt.as_ref() {\n                syn::Type::Path(tp) => {\n                    let segs = &tp.path.segments;\n                    Self::get_deserializer_output_for_result(segs, optional, vec, &expected_type)\n                }\n                _ => Err(syn::Error::new(\n                    tp.span(),\n                    format!(\"Return type should be {}\", expected_type),\n                )),\n            },\n        };\n        s\n    }\n\n    fn get_deserializer_output_for_result(","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube/cubesqlplanner/nativebridge/src/lib.rs#L214-L250","documentation":"get_output_for_deserializer requires each bridged method to declare an explicit return type, because the macro must build a deserializer for the concrete output shape (Result<_>, Option<_>, Vec<_> wrappers are tracked via `optional`/`vec`). A bare `fn f(&self);` with no `-> T` (ReturnType::Default) gives the macro nothing to deserialize, so it fails with the computed expected type in the message.","triggerScenarios":"Declaring a native_bridge trait method without a return type, e.g. `fn execute(&self);` — the macro then reports `Return type should be Result<_>` (or the Option/Vec-augmented expectation).","commonSituations":"Writing RPC-style methods that 'return nothing' out of habit, porting plain Rust traits into a native_bridge service without adding Result returns.","solutions":["Add an explicit return type to the method — every bridged method must return something, normally `Result<_>`.","Use `Result<Option<T>>` or `Result<Vec<T>>` when optional/collection outputs are needed, since those shapes are explicitly supported.","Never leave the return type off; even unit-returning methods must be changed to return a Result."],"exampleFix":"// before\n#[native_bridge]\ntrait MyService {\n    fn query(&self);\n}\n\n// after\n#[native_bridge]\ntrait MyService {\n    fn query(&self) -> Result<String>;\n}","handlingStrategy":"validation","validationCode":"// Reject methods with no return type before building the service\nfn has_return_type(sig: &str) -> bool {\n    sig.contains(\"->\")\n}\n// assert!(has_return_type(\"fn query(&self) -> Result<String>;\"));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every bridged method an explicit `-> Result<T>` return type","Treat 'returns nothing' as a design smell on the bridge boundary","Lint trait definitions with a custom test that asserts `->` appears in each signature"],"tags":["proc-macro","compile-time","rust","type-signature"],"backgroundTag":"missing-return-type","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}