go-redis/redis · error
redis: no valid results to aggregate for logical AND operati
Error message
redis: no valid results to aggregate for logical AND operation
What it means
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.
Source
Thrown at internal/routing/aggregator.go:18
package routing
import (
"errors"
"fmt"
"math"
"sync"
"sync/atomic"
"github.com/redis/go-redis/v9/internal/util"
uberAtomic "go.uber.org/atomic"
)
var (
ErrMaxAggregation = errors.New("redis: no valid results to aggregate for max operation")
ErrMinAggregation = errors.New("redis: no valid results to aggregate for min operation")
ErrAndAggregation = errors.New("redis: no valid results to aggregate for logical AND operation")
ErrOrAggregation = errors.New("redis: no valid results to aggregate for logical OR operation")
)
// ResponseAggregator defines the interface for aggregating responses from multiple shards.
type ResponseAggregator interface {
// Add processes a single shard response.
Add(result interface{}, err error) error
// AddWithKey processes a single shard response for a specific key (used by keyed aggregators).
AddWithKey(key string, result interface{}, err error) error
BatchAdd(map[string]AggregatorResErr) error
BatchSlice([]AggregatorResErr) error
// Result returns the final aggregated result and any error.
Result() (interface{}, error)
}View on GitHub (pinned to 36d97525cd)
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).
Example fix
// before
res, err := clusterClient.BoolAndCmd(ctx)
// after
res, err := clusterClient.BoolAndCmd(ctx)
if errors.Is(err, routing.ErrAndAggregation) {
return false, nil // no valid shard results
} Defensive patterns
Strategy: try-catch
Validate before calling
// No app-level pre-check; ensure all shards healthy and command returns booleans.
Try / catch
res, err := clusterClient.BoolAndCmd(ctx)
if errors.Is(err, routing.ErrAndAggregation) {
return false, nil
} Prevention
- 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.
When it happens
Trigger: A ClusterClient command using RespAggLogicalAnd where every shard errored or none returned a boolean, so the AND has no operands.
Common situations: Cluster-wide failures, all shards returning errors, or a command mis-mapped to agg_logical_and when its results aren't boolean.
Related errors
- redis: no valid results to aggregate for max operation
- redis: no valid results to aggregate for logical OR operatio
- redis: cluster has no nodes
- redis: cannot pipeline command %q with request policy ReqAll
- redis: multi-shard command %s has no key arguments
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/e631f23592395961.json.
Report an issue: GitHub.