{"record":{"id":"5562c5d458cf7820","repo":"cube-js/cube","slug":"return-type-should-be-result","errorCode":null,"errorMessage":"Return type should be Result<_>","messagePattern":"Return type should be Result<_>","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"rust/cube/cubesqlplanner/nativebridge/src/lib.rs","lineNumber":256,"sourceCode":"                    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(\n        segs: &Punctuated<PathSegment, PathSep>,\n        optional: bool,\n        vec: bool,\n        expected_type: &str,\n    ) -> syn::Result<NativeOutputParams> {\n        let seg = segs.last().ok_or(syn::Error::new(\n            segs.span(),\n            \"Return type should be Result<_>\",\n        ))?;\n        if seg.ident.to_string() == \"Result\" {\n            let mut args = seg.arguments.clone();\n            if optional {\n                args = Self::extract_output_for_nested_type(&args, \"Option\", expected_type)?;\n            }\n            if vec {\n                args = Self::extract_output_for_nested_type(&args, \"Vec\", expected_type)?;\n            }\n            Self::get_type_for_deserialize_from_result_args(&args, expected_type)\n        } else {\n            Err(syn::Error::new(\n                seg.span(),\n                \"Return type should be Result<_>\",\n            ))\n        }","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube/cubesqlplanner/nativebridge/src/lib.rs#L238-L274","documentation":"get_deserializer_output_for_result inspects the last path segment of the return type and requires that it exists and is `Result`. If the segments are empty (malformed/edge-case path) the ok_or fallback emits 'Return type should be Result<_>'. This is the guard ensuring every bridged method's output is a Result-shaped wrapper before deserializing its inner type.","triggerScenarios":"A return type whose path resolves with no final segment when reaching this helper — practically seen with unusual type paths or when this function is invoked on segments extracted from a type that is not a plain wrapper.","commonSituations":"Rare; usually encountered when the macro's type parsing is fed an exotic path type or after refactoring return types into aliases the macro cannot resolve.","solutions":["Return a plain `Result<T>` (possibly `Result<Option<T>>` / `Result<Vec<T>>`) from the bridged method.","Avoid deeply nested or aliased exotic type paths in bridge method signatures.","If using type aliases, expand them to the concrete Result shape in the trait signature."],"exampleFix":"// before\ntype Out = std::result::Result<String, Error>;\nfn query(&self) -> Out;\n\n// after\nfn query(&self) -> Result<String>;","handlingStrategy":"validation","validationCode":"// Expand aliases: keep the literal Result<...> in the signature\nfn uses_literal_result(sig: &str) -> bool {\n    sig.contains(\"-> Result<\")\n}\n// assert!(uses_literal_result(\"fn q(&self) -> Result<String>;\"));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write Result<_> literally in bridge method signatures instead of type aliases","Keep type paths simple; avoid deeply qualified nested paths","Document the required Result shape next to the trait"],"tags":["proc-macro","compile-time","rust","type-signature"],"backgroundTag":"unsupported-return-type","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}