{"id":"2e4ac1bae0ab87c4","repo":"go-redis/redis","slug":"redis-no-valid-results-to-aggregate-for-logical-o","errorCode":null,"errorMessage":"redis: no valid results to aggregate for logical OR operation","messagePattern":"redis: no valid results to aggregate for logical OR operation","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/routing/aggregator.go","lineNumber":19,"sourceCode":"package routing\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"sync\"\n\n\t\"sync/atomic\"\n\n\t\"github.com/redis/go-redis/v9/internal/util\"\n\tuberAtomic \"go.uber.org/atomic\"\n)\n\nvar (\n\tErrMaxAggregation = errors.New(\"redis: no valid results to aggregate for max operation\")\n\tErrMinAggregation = errors.New(\"redis: no valid results to aggregate for min operation\")\n\tErrAndAggregation = errors.New(\"redis: no valid results to aggregate for logical AND operation\")\n\tErrOrAggregation  = errors.New(\"redis: no valid results to aggregate for logical OR operation\")\n)\n\n// ResponseAggregator defines the interface for aggregating responses from multiple shards.\ntype ResponseAggregator interface {\n\t// Add processes a single shard response.\n\tAdd(result interface{}, err error) error\n\n\t// AddWithKey processes a single shard response for a specific key (used by keyed aggregators).\n\tAddWithKey(key string, result interface{}, err error) error\n\n\tBatchAdd(map[string]AggregatorResErr) error\n\n\tBatchSlice([]AggregatorResErr) error\n\n\t// Result returns the final aggregated result and any error.\n\tResult() (interface{}, error)\n}\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/routing/aggregator.go#L1-L37","documentation":"routing.ErrOrAggregation is returned by AggLogicalOrAggregator.Result() when no shard contributed a boolean result (aggregator.go:626-628). The OR aggregator only has a value once at least one Add stored a boolean; if all shards errored or none were added, hasResult is false and Result fails.","triggerScenarios":"A ClusterClient command using RespAggLogicalOr where every shard errored or none returned a boolean, leaving the OR with no operands.","commonSituations":"Cluster node failures during fan-out, command mis-mapped to agg_logical_or, or all shards returning errors.","solutions":["Check per-shard errors to locate the failing node(s).","Verify the response policy (agg_logical_or) fits the command's boolean output.","Handle the empty-aggregation case explicitly (e.g. default false)."],"exampleFix":"// before\nres, err := clusterClient.BoolOrCmd(ctx)\n// after\nres, err := clusterClient.BoolOrCmd(ctx)\nif errors.Is(err, routing.ErrOrAggregation) {\n    return false, nil\n}","handlingStrategy":"try-catch","validationCode":"// No app-level pre-check; ensure all shards healthy and command returns booleans.","typeGuard":null,"tryCatchPattern":"res, err := clusterClient.BoolOrCmd(ctx)\nif errors.Is(err, routing.ErrOrAggregation) {\n    return false, nil\n}","preventionTips":["Maintain cluster shard availability for complete fan-outs.","Match the command to agg_logical_or only when output is boolean.","Handle the no-results case explicitly."],"tags":["cluster","routing","aggregation","logical-or","fan-out"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}