{"id":"a9f5a6e44abd4c60","repo":"go-redis/redis","slug":"redis-unknown-message-t","errorCode":null,"errorMessage":"redis: unknown message: %T","messagePattern":"redis: unknown message: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pubsub.go","lineNumber":550,"sourceCode":"// ReceiveMessage returns a Message or error ignoring Subscription and Pong\n// messages. This is low-level API and in most cases Channel should be used\n// instead.\nfunc (c *PubSub) ReceiveMessage(ctx context.Context) (*Message, error) {\n\tfor {\n\t\tmsg, err := c.Receive(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tswitch msg := msg.(type) {\n\t\tcase *Subscription:\n\t\t\t// Ignore.\n\t\tcase *Pong:\n\t\t\t// Ignore.\n\t\tcase *Message:\n\t\t\treturn msg, nil\n\t\tdefault:\n\t\t\terr := fmt.Errorf(\"redis: unknown message: %T\", msg)\n\t\t\treturn nil, err\n\t\t}\n\t}\n}\n\nfunc (c *PubSub) getContext() context.Context {\n\tif c.cmd != nil {\n\t\treturn c.cmd.ctx\n\t}\n\treturn context.Background()\n}\n\n//------------------------------------------------------------------------------\n\n// Channel returns a Go channel for concurrently receiving messages.\n// The channel is closed together with the PubSub. If the Go channel\n// is blocked full for 1 minute the message is dropped.\n// Receive* APIs can not be used after channel is created.","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/pubsub.go#L532-L568","documentation":"Error \"redis: unknown message: %T\" thrown in go-redis/redis.","triggerScenarios":"Thrown at pubsub.go:550 when the library encounters an invalid state.","commonSituations":"Always include a default branch in pubsub message type switches.","solutions":["Type-switch on known message types (Message, Pong, Subscription) before casting","Extend the switch for the type shown in the error"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}