{"record":{"id":"adb7747dc6f3a7ec","repo":"redis/jedis","slug":"unknown-message-type","errorCode":null,"errorMessage":"Unknown message type: ","messagePattern":"Unknown message type: ","errorType":"exception","errorClass":"JedisException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/JedisShardedPubSubBase.java","lineNumber":113,"sourceCode":"          final T enchannel = (bchannel == null) ? null : encode(bchannel);\n          onSUnsubscribe(enchannel, subscribedChannels);\n        } else if (Arrays.equals(SMESSAGE.getRaw(), resp)) {\n          final byte[] bchannel = (byte[]) listReply.get(1);\n          final byte[] bmesg = (byte[]) listReply.get(2);\n          final T enchannel = (bchannel == null) ? null : encode(bchannel);\n          final T enmesg = (bmesg == null) ? null : encode(bmesg);\n          onSMessage(enchannel, enmesg);\n        } else {\n          throw new JedisException(\"Unknown message type: \" + firstObj);\n        }\n      } else if (reply instanceof byte[]) {\n        Consumer<Object> resultHandler = authenticator.resultHandler.poll();\n        if (resultHandler == null) {\n          throw new JedisException(\"Unexpected message : \" + SafeEncoder.encode((byte[]) reply));\n        }\n        resultHandler.accept(reply);\n      } else {\n        throw new JedisException(\"Unknown message type: \" + reply);\n      }\n    } while (!Thread.currentThread().isInterrupted() && isSubscribed());\n\n//    /* Invalidate instance since this thread is no longer listening */\n//    this.client = null;\n  }\n}\n","sourceCodeStart":95,"sourceCodeEnd":121,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/JedisShardedPubSubBase.java#L95-L121","documentation":"The final else-branch of JedisShardedPubSubBase.process() fires when the reply object is neither a List nor a byte[] — some other type arrived on the sharded pub/sub connection. It throws JedisException(\"Unknown message type: \" + reply), meaning the client cannot classify the incoming object at all.","triggerScenarios":"proceed() receives a reply object that is not a List (pub/sub message) and not a byte[] (command ack) — e.g. a Long, a nested structure, or a RESP3 push-typed object this version doesn't decode.","commonSituations":"RESP3 push frames reaching a client built for RESP2 parsing; server/proxy sending malformed or novel reply shapes; connection state corruption after a previous error.","solutions":["Use RESP3 consistently when token auth or push features are enabled; otherwise ensure RESP2 end-to-end.","Upgrade Jedis so newer reply/push shapes are recognized.","Dedicate the connection to sharded pub/sub and avoid middleware that rewrites RESP.","On catch, close the connection and re-create the subscription from scratch."],"exampleFix":"// before\nRedisClient.builder().protocol(RedisProtocol.RESP2).build(); // push frames mis-parsed\n// after\nRedisClient.builder().protocol(RedisProtocol.RESP3).build(); // push-aware parsing","handlingStrategy":"try-catch","validationCode":"boolean protocolSupported(RedisProtocol p) { return p == RedisProtocol.RESP2 || p == RedisProtocol.RESP3; }","typeGuard":"boolean isClassifiableReply(Object reply) {\n  return reply instanceof List || reply instanceof byte[];\n}","tryCatchPattern":"try {\n  shardedPubSub.proceed(jedis, channel);\n} catch (JedisException e) {\n  if (e.getMessage().startsWith(\"Unknown message type\")) {\n    jedis.close(); // rebuild connection with correct protocol\n  } else throw e;\n}","preventionTips":["Match client protocol to server capabilities (RESP3 for push features).","Remove or fix proxies that produce non-standard RESP objects.","Upgrade Jedis to parse newer push/reply shapes.","Re-create connections after any protocol-level error."],"tags":["pubsub","protocol","redis"],"backgroundTag":"unexpected-response-shape","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}