redis/go-redis · error

at least one channel is required

Error message

at least one channel is required

What it means

Error "at least one channel is required" thrown in redis/go-redis.

Source

Thrown at ring.go:735

			pipe.StaleConns += ps.StaleConns
			havePipe = true
		}
	}
	if havePipe {
		acc.PipelineStats = &pipe
	}
	return &acc
}

// Len returns the current number of shards in the ring.
func (c *Ring) Len() int {
	return c.sharding.Len()
}

// Subscribe subscribes the client to the specified channels.
func (c *Ring) Subscribe(ctx context.Context, channels ...string) *PubSub {
	if len(channels) == 0 {
		panic("at least one channel is required")
	}

	shard, err := c.sharding.GetByKey(channels[0])
	if err != nil {
		// TODO: return PubSub with sticky error
		panic(err)
	}
	return shard.Client.Subscribe(ctx, channels...)
}

// PSubscribe subscribes the client to the given patterns.
func (c *Ring) PSubscribe(ctx context.Context, channels ...string) *PubSub {
	if len(channels) == 0 {
		panic("at least one channel is required")
	}

	shard, err := c.sharding.GetByKey(channels[0])
	if err != nil {

View on GitHub (pinned to c5cad058c7)

When it happens

Trigger: Thrown at ring.go:735 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01). Data as JSON: /api/errors/f98607ec05e15cde. Report an issue: GitHub.