{"id":"e631f23592395961","repo":"go-redis/redis","slug":"redis-no-valid-results-to-aggregate-for-logical-a","errorCode":null,"errorMessage":"redis: no valid results to aggregate for logical AND operation","messagePattern":"redis: no valid results to aggregate for logical AND operation","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/routing/aggregator.go","lineNumber":18,"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}","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/routing/aggregator.go#L1-L36","documentation":"routing.ErrAndAggregation is returned by AggLogicalAndAggregator.Result() when no shard contributed a boolean result (aggregator.go:543-545). hasResult stays false unless at least one Add stored a boolean, so an entirely empty/errored fan-out yields this error.","triggerScenarios":"A ClusterClient command using RespAggLogicalAnd where every shard errored or none returned a boolean, so the AND has no operands.","commonSituations":"Cluster-wide failures, all shards returning errors, or a command mis-mapped to agg_logical_and when its results aren't boolean.","solutions":["Inspect the per-shard errors to find which node(s) failed.","Confirm the command's response policy (agg_logical_and) matches boolean-producing output.","Treat the aggregation-empty case explicitly in the caller (e.g. default to false)."],"exampleFix":"// before\nres, err := clusterClient.BoolAndCmd(ctx)\n// after\nres, err := clusterClient.BoolAndCmd(ctx)\nif errors.Is(err, routing.ErrAndAggregation) {\n    return false, nil // no valid shard results\n}","handlingStrategy":"try-catch","validationCode":"// No app-level pre-check; ensure all shards healthy and command returns booleans.","typeGuard":null,"tryCatchPattern":"res, err := clusterClient.BoolAndCmd(ctx)\nif errors.Is(err, routing.ErrAndAggregation) {\n    return false, nil\n}","preventionTips":["Keep cluster shards reachable to avoid empty aggregations.","Confirm the command's agg_logical_and policy fits boolean output.","Default the empty case to false in caller logic."],"tags":["cluster","routing","aggregation","logical-and","fan-out"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}