{"record":{"id":"73773c2c2436b692","repo":"cube-js/cube","slug":"return-type-should-be-expected-type","errorCode":null,"errorMessage":"Return type should be {expected_type}","messagePattern":"Return type should be (.+?)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"rust/cube/cubesqlplanner/nativebridge/src/lib.rs","lineNumber":288,"sourceCode":"            Err(syn::Error::new(\n                seg.span(),\n                \"Return type should be Result<_>\",\n            ))\n        }\n    }\n\n    fn extract_output_for_nested_type(\n        args: &PathArguments,\n        type_to_extract: &str,\n        expected_type: &str,\n    ) -> syn::Result<PathArguments> {\n        let error_message = format!(\"Return type should be {expected_type}\");\n        match args {\n            syn::PathArguments::AngleBracketed(args) => {\n                let arg = args\n                    .args\n                    .first()\n                    .ok_or(syn::Error::new(args.span(), error_message.clone()))?;\n                match arg {\n                    syn::GenericArgument::Type(tp) => match tp {\n                        Type::Path(tp) => {\n                            let segs = &tp.path.segments;\n                            let seg = segs.last().ok_or(syn::Error::new(\n                                tp.span(),\n                                \"Return type should be Result<Option<_>>\",\n                            ))?;\n                            if seg.ident.to_string() == type_to_extract {\n                                let args = &seg.arguments;\n                                Ok(args.clone())\n                            } else {\n                                Err(syn::Error::new(seg.span(), error_message.clone()))\n                            }\n                        }\n                        _ => Err(syn::Error::new(arg.span(), error_message.clone())),\n                    },\n                    _ => Err(syn::Error::new(arg.span(), error_message.clone())),","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube/cubesqlplanner/nativebridge/src/lib.rs#L270-L306","documentation":"extract_output_for_nested_type unwraps one level of generic arguments (Option or Vec, per `type_to_extract`) from the Result's inner type. If the angle-bracketed argument list is empty — i.e. `Result<>`-like degenerate generics — there is no first generic argument to unwrap, and the helper fails with 'Return type should be {expected_type}' (expected_type is built as e.g. 'Result<Option<_>>').","triggerScenarios":"A Result inner type whose generic argument list yields nothing to extract; practically triggered when the nested wrapper has no type parameter the macro can pull out.","commonSituations":"Degenerate or partially-written generic signatures during refactoring, or mismatched expectations where the developer wrote a wrapper without its type parameter.","solutions":["Provide the type parameter on the nested wrapper: write `Result<Option<T>>` / `Result<Vec<T>>` fully, never a bare wrapper without generics.","Check for stray angle brackets or removed generics after refactoring.","Compile a minimal example to confirm the exact signature the macro accepts."],"exampleFix":"// before\nfn query(&self) -> Result<Option>;\n\n// after\nfn query(&self) -> Result<Option<String>>;","handlingStrategy":"validation","validationCode":"fn nested_has_type_param(sig: &str) -> bool {\n    // e.g. \"Result<Option<String>>\" — wrapper must carry a type parameter\n    sig.contains(\"Option<\") || sig.contains(\"Vec<\")\n}\n// assert!(nested_has_type_param(\"Result<Option<String>>\"));\n// assert!(!nested_has_type_param(\"Result<Option>\")); // would fail","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply the generic parameter on Option/Vec inside Result","Check for dangling angle brackets after refactors","Compile after every signature change rather than batching edits"],"tags":["proc-macro","compile-time","rust","generics"],"backgroundTag":"unsupported-return-type","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}