go-redis/redis · error

redis: no valid results to aggregate for logical OR operatio

Error message

redis: no valid results to aggregate for logical OR operation

What it means

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.

Source

Thrown at internal/routing/aggregator.go:19

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

  1. Check per-shard errors to locate the failing node(s).
  2. Verify the response policy (agg_logical_or) fits the command's boolean output.
  3. Handle the empty-aggregation case explicitly (e.g. default false).

Example fix

// before
res, err := clusterClient.BoolOrCmd(ctx)
// after
res, err := clusterClient.BoolOrCmd(ctx)
if errors.Is(err, routing.ErrOrAggregation) {
    return false, nil
}
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.BoolOrCmd(ctx)
if errors.Is(err, routing.ErrOrAggregation) {
    return false, nil
}

Prevention

When it happens

Trigger: A ClusterClient command using RespAggLogicalOr where every shard errored or none returned a boolean, leaving the OR with no operands.

Common situations: Cluster node failures during fan-out, command mis-mapped to agg_logical_or, or all shards returning errors.

Related errors


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/2e4ac1bae0ab87c4.json. Report an issue: GitHub.