{"record":{"id":"3bee920af733d236","repo":"cube-js/cube","slug":"only-trait-can-be-annotated-as-a-service-3bee92","errorCode":null,"errorMessage":"Only trait can be annotated as a service","messagePattern":"Only trait can be annotated as a service","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"rust/cubestore/cuberpc/src/lib.rs","lineNumber":85,"sourceCode":"                    .iter()\n                    .filter_map(|item| match item {\n                        TraitItem::Method(method_item) => Some(RpcMethod {\n                            ident: method_item.sig.ident.clone(),\n                            args: method_item.sig.inputs.iter().cloned().collect::<Vec<_>>(),\n                            output: method_item.sig.output.clone(),\n                            asyncness: method_item.sig.asyncness.is_some(),\n                        }),\n                        _ => None,\n                    })\n                    .collect::<Vec<_>>();\n                RpcService {\n                    ident: trait_item.ident.clone(),\n                    methods,\n                    trace_guard: None,\n                }\n            }\n            x => {\n                return Err(syn::Error::new(\n                    x.span(),\n                    \"Only trait can be annotated as a service\",\n                ))\n            }\n        };\n        Ok(svc)\n    }\n}\n\nimpl RpcService {\n    fn original_trait(&self) -> proc_macro2::TokenStream {\n        let service_ident = &self.ident;\n        let methods = self\n            .methods\n            .iter()\n            .map(|m| m.original_method())\n            .collect::<Vec<_>>();\n        // TODO Supertraits","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cuberpc/src/lib.rs#L67-L103","documentation":"The #[cuberpc::service] macro only transforms traits (it walks TraitItem::Method entries to generate RPC scaffolding), but it was applied to a non-trait item such as a struct, enum, or impl block. This is a compile-time authoring error in the annotated Rust source.","triggerScenarios":"Thrown at rust/cubestore/cuberpc/src/lib.rs:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Apply #[cuberpc::service] to a trait definition whose methods become the RPC surface","Use the appropriate macro or plain code for non-trait items"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}