go-redis/redis · error
redis: unknown message: %T
Error message
redis: unknown message: %T
What it means
Error "redis: unknown message: %T" thrown in go-redis/redis.
Source
Thrown at pubsub.go:550
// ReceiveMessage returns a Message or error ignoring Subscription and Pong
// messages. This is low-level API and in most cases Channel should be used
// instead.
func (c *PubSub) ReceiveMessage(ctx context.Context) (*Message, error) {
for {
msg, err := c.Receive(ctx)
if err != nil {
return nil, err
}
switch msg := msg.(type) {
case *Subscription:
// Ignore.
case *Pong:
// Ignore.
case *Message:
return msg, nil
default:
err := fmt.Errorf("redis: unknown message: %T", msg)
return nil, err
}
}
}
func (c *PubSub) getContext() context.Context {
if c.cmd != nil {
return c.cmd.ctx
}
return context.Background()
}
//------------------------------------------------------------------------------
// Channel returns a Go channel for concurrently receiving messages.
// The channel is closed together with the PubSub. If the Go channel
// is blocked full for 1 minute the message is dropped.
// Receive* APIs can not be used after channel is created.View on GitHub (pinned to 36d97525cd)
Solutions
- Type-switch on known message types (Message, Pong, Subscription) before casting
- Extend the switch for the type shown in the error
When it happens
Trigger: Thrown at pubsub.go:550 when the library encounters an invalid state.
Common situations: Always include a default branch in pubsub message type switches.
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/a9f5a6e44abd4c60.json.
Report an issue: GitHub.