{"record":{"id":"ea94cb063b22e77b","repo":"weaviate/weaviate","slug":"malformed-numerical-aggregator-state-in-shard-resu","errorCode":null,"errorMessage":"malformed numerical aggregator state in shard result","messagePattern":"malformed numerical aggregator state in shard result","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/aggregator/shard_combiner.go","lineNumber":357,"sourceCode":"\t\tcase \"_dateAggregator\":\n\t\t\tcontinue\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown aggregation %q in shard result\", propType)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (sc *ShardCombiner) mergeNumericalProp(first, second map[string]interface{}) error {\n\tif len(second) == 0 {\n\t\treturn nil\n\t}\n\n\t// merge the raw distributions first, so that mode/mean/median recompute over both shards\n\tif source, ok := second[\"_numericalAggregator\"]; ok {\n\t\tsourceTyped, ok := source.(*numericalAggregator)\n\t\tif !ok {\n\t\t\treturn errors.New(\"malformed numerical aggregator state in shard result\")\n\t\t}\n\t\tif combined, ok := first[\"_numericalAggregator\"]; ok {\n\t\t\tcombinedTyped, ok := combined.(*numericalAggregator)\n\t\t\tif !ok {\n\t\t\t\treturn errors.New(\"malformed numerical aggregator state in shard result\")\n\t\t\t}\n\t\t\tcombinedTyped.absorb(sourceTyped)\n\t\t} else {\n\t\t\tfirst[\"_numericalAggregator\"] = source\n\t\t}\n\t}\n\n\tfor propType, value := range second {\n\t\tswitch propType {\n\t\tcase \"count\", \"sum\":\n\t\t\tsourceVal, ok := value.(float64)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"malformed %q entry in shard result\", propType)","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/aggregator/shard_combiner.go#L339-L375","documentation":"Raised by mergeNumericalProp in the shard combiner when the source shard's grouped result contains a `_numericalAggregator` entry whose runtime type is not *numericalAggregator. The combiner merges raw distributions from each shard so mode/mean/median can be recomputed over the union; a wrong-typed entry makes that impossible.","triggerScenarios":"Group-by numerical aggregation across shards where `second[\"_numericalAggregator\"]` exists but holds something other than *numericalAggregator (type assertion failure on the source map value).","commonSituations":"Mixed-version clusters with changed internal aggregation types; corrupted or hand-crafted shard group maps; unit tests (testNumbers) that populate group maps with the wrong concrete type.","solutions":["Ensure all cluster nodes run a compatible Weaviate version and retry the aggregation","Isolate the offending shard by aggregating shard-by-shard","Restore/rebuild the corrupt shard from backup or re-index its data","Fix test helpers so `_numericalAggregator` is always a *numericalAggregator (e.g. newNumericalAggregator(...))"],"exampleFix":"// before\ncombined[\"_numericalAggregator\"] = struct{ count int }{count: 5}\n// after\ncombined[\"_numericalAggregator\"] = newNumericalAggregator()","handlingStrategy":"type-guard","validationCode":"func hasTypedNumericalAggregator(group map[string]interface{}) bool {\n\t_, ok := group[\"_numericalAggregator\"].(*numericalAggregator)\n\treturn ok\n}","typeGuard":"if agg, ok := group[\"_numericalAggregator\"].(*numericalAggregator); ok {\n\tcombined.absorb(agg)\n} else {\n\treturn fmt.Errorf(\"malformed numerical aggregator state in shard result\")\n}","tryCatchPattern":"if err := combine(results); err != nil {\n\tif strings.Contains(err.Error(), \"malformed numerical aggregator state\") {\n\t\t// retry per-shard or drop the offending shard's contribution\n\t}\n}","preventionTips":["Keep cluster versions homogeneous","Populate `_numericalAggregator` only via newNumericalAggregator constructors","Don't deserialize shard results with lossy generic codecs","Add unit tests that exercise the full merge path"],"tags":["aggregation","internal-state","type-assertion","shard-merge"],"backgroundTag":"corrupt-aggregator-state","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}