{"record":{"id":"2495cc753ad557a8","repo":"risingwavelabs/risingwave","slug":"unrecognized-agg","errorCode":null,"errorMessage":"Unrecognized agg.","messagePattern":"Unrecognized agg\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/expr/core/src/aggregate/def.rs","lineNumber":276,"sourceCode":"    }\n}\n\nimpl AggType {\n    pub fn from_protobuf_flatten(\n        pb_kind: PbAggKind,\n        user_defined: Option<&PbUserDefinedFunctionMetadata>,\n        scalar: Option<&PbExprNode>,\n    ) -> Result<Self> {\n        match pb_kind {\n            PbAggKind::UserDefined => {\n                let user_defined = user_defined.context(\"expect user defined\")?;\n                Ok(AggType::UserDefined(user_defined.clone()))\n            }\n            PbAggKind::WrapScalar => {\n                let scalar = scalar.context(\"expect scalar\")?;\n                Ok(AggType::WrapScalar(scalar.clone()))\n            }\n            PbAggKind::Unspecified => bail!(\"Unrecognized agg.\"),\n            _ => Ok(AggType::Builtin(pb_kind)),\n        }\n    }\n\n    pub fn to_protobuf_simple(&self) -> PbAggKind {\n        match self {\n            Self::Builtin(pb) => *pb,\n            Self::UserDefined(_) => PbAggKind::UserDefined,\n            Self::WrapScalar(_) => PbAggKind::WrapScalar,\n        }\n    }\n\n    pub fn from_protobuf(pb_type: &PbAggType) -> Result<Self> {\n        match PbAggKind::try_from(pb_type.kind).context(\"no such aggregate function type\")? {\n            PbAggKind::Unspecified => bail!(\"Unrecognized agg.\"),\n            PbAggKind::UserDefined => Ok(AggType::UserDefined(pb_type.get_udf_meta()?.clone())),\n            PbAggKind::WrapScalar => Ok(AggType::WrapScalar(pb_type.get_scalar_expr()?.clone())),\n            kind => Ok(AggType::Builtin(kind)),","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/core/src/aggregate/def.rs#L258-L294","documentation":"AggType::from_protobuf_flatten converts a protobuf AggKind into the internal AggType. PbAggKind::Unspecified is the protobuf zero-value; encountering it means the sender did not set the agg kind field (or sent a corrupt/default message), so the parser cannot determine which aggregate to build and bails with \"Unrecognized agg.\"","triggerScenarios":"Deserializing an Aggregate protocol buffer whose agg_kind field is left Unspecified — e.g. a hand-built PbAggNode without setting kind, a schema/version mismatch where the kind field was dropped, or serialization bugs upstream.","commonSituations":"Writing plan protobufs by hand or via codegen and forgetting to set agg_kind; cross-version plan exchange where a newer kind is unknown to the older binary and defaults to Unspecified; corrupted plan fragments.","solutions":["Ensure the plan builder sets the agg_kind field explicitly to a valid PbAggKind before serializing.","Check for version skew between the component producing the plan and the one consuming it; align versions.","Validate the generated plan protobuf (e.g. with prost validation or a unit test) that agg_kind != Unspecified."],"exampleFix":"// before\nlet node = PbAggNode { agg_calls: vec![PbAggCall { .., /* agg_kind omitted */ }] };\n// after\nlet node = PbAggNode { agg_calls: vec![PbAggCall { .., agg_kind: PbAggKind::Sum as i32 }] };","handlingStrategy":"validation","validationCode":"// before sending plan protobuf\nfor (const call of aggNode.agg_calls) {\n  if (call.agg_kind === PbAggKind.Unspecified) throw new Error(\"agg_kind must be set\");\n}","typeGuard":"function hasAggKind(call) { return call.agg_kind !== undefined && call.agg_kind !== PbAggKind.Unspecified; }","tryCatchPattern":"match AggType::from_protobuf_flatten(&pb) {\n    Ok(agg) => agg,\n    Err(e) if e.to_string().contains(\"Unrecognized agg\") => bail!(\"plan produced unset agg_kind; check plan builder version\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Always set agg_kind explicitly when constructing PbAggCall","Keep plan producer/consumer versions aligned","Add unit tests asserting no Unspecified enum values in generated plans"],"tags":["protobuf","aggregate","deserialization"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}