go-redis/redis · error

cannot convert %T to bool

Error message

cannot convert %T to bool

What it means

Error "cannot convert %T to bool" thrown in go-redis/redis.

Source

Thrown at internal/routing/aggregator.go:686

		return float64(v), nil
	default:
		return 0, fmt.Errorf("cannot convert %T to float64", val)
	}
}

func toBool(val interface{}) (bool, error) {
	if val == nil {
		return false, nil
	}
	switch v := val.(type) {
	case bool:
		return v, nil
	case int64:
		return v != 0, nil
	case int:
		return v != 0, nil
	default:
		return false, fmt.Errorf("cannot convert %T to bool", val)
	}
}

// DefaultKeylessAggregator collects all results in an array, order doesn't matter.
type DefaultKeylessAggregator struct {
	mu       sync.Mutex
	results  []interface{}
	firstErr error
}

func (a *DefaultKeylessAggregator) add(result interface{}, err error) error {
	if err != nil && a.firstErr == nil {
		a.firstErr = err
		return nil
	}
	if err == nil {
		a.results = append(a.results, result)
	}

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Ensure values are bool/int before boolean aggregation
  2. Convert string results ('0'/'1') explicitly before aggregating

When it happens

Trigger: Thrown at internal/routing/aggregator.go:686 when the library encounters an invalid state.

Common situations: Normalize shard results to bool before logical aggregation.


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