{"record":{"id":"06c060ab76448b35","repo":"redis/jedis","slug":"unsupported-protocol","errorCode":null,"errorMessage":"Unsupported protocol: ","messagePattern":"Unsupported protocol: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/ProtocolHandshake.java","lineNumber":73,"sourceCode":"   * @throws JedisDataException if the server returns an error during handshake\n   */\n  HelloResult establish(final RedisProtocol requestedProtocol, final boolean autoNegotiateProtocol,\n      final RedisCredentials credentials) {\n    if (requestedProtocol == null) {\n      if (autoNegotiateProtocol) {\n        return negotiateResp3WithFallback(credentials);\n      }\n      // Legacy compatibility: skip HELLO entirely, only authenticate if credentials are provided.\n      // Connection assumes RESP2 on the wire.\n      connection.authenticate(credentials);\n      return new HelloResult(\n          Collections.singletonMap(\"proto\", Long.valueOf(RedisProtocol.RESP2.version())));\n    } else if (requestedProtocol == RedisProtocol.RESP2) {\n      return enforceProtocolWithAuth(RedisProtocol.RESP2, credentials);\n    } else if (requestedProtocol == RedisProtocol.RESP3) {\n      return enforceProtocolWithAuth(RedisProtocol.RESP3, credentials);\n    } else {\n      throw new IllegalArgumentException(\"Unsupported protocol: \" + requestedProtocol);\n    }\n  }\n\n  /**\n   * Send HELLO command to the server to negotiate the protocol version and authenticate if needed.\n   * <p>\n   * Attempts RESP3 handshake, falls back to RESP2 if not supported.\n   * </p>\n   * @param credentials credentials for authentication\n   * @return {@link HelloResult} the actual negotiated protocol version\n   */\n  private HelloResult negotiateResp3WithFallback(final RedisCredentials credentials) {\n    try {\n      return enforceProtocolWithAuth(RedisProtocol.RESP3, credentials);\n    } catch (JedisProtocolNotSupportedException e) {\n      // fall back to resp2\n      return establishLegacyResp2(credentials);\n    } catch (JedisDataException e) {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/ProtocolHandshake.java#L55-L91","documentation":"ProtocolHandshake.establish() switches on the requested RedisProtocol and only knows RESP2 and RESP3. Any other value (null, a future/unknown protocol enum value) is rejected with IllegalArgumentException \"Unsupported protocol: X\" before the HELLO handshake is attempted.","triggerScenarios":"Building a client (JedisClientConfig) with a RedisProtocol value other than RedisProtocol.RESP2 or RESP3 — typically null parsed from config or an unhandled enum constant from a newer Jedis/other library.","commonSituations":"Protocol version read from external config (string mapped incorrectly to enum), copy-paste of protocol constants from another library, or upgrades where a new enum value meets an old jar.","solutions":["Set the protocol explicitly to RedisProtocol.RESP2 or RedisProtocol.RESP3.","Omit the protocol setting to use the library default.","Fix the string-to-enum mapping in your config loader.","Align Jedis versions so only known RedisProtocol values are referenced."],"exampleFix":"// before\nJedisClientConfig config = DefaultJedisClientConfig.builder()\n    .protocol(parseProtocol(cfg.get(\"redis.protocol\"))) // returns null -> throws\n    .build();\n\n// after\nRedisProtocol proto = parseProtocol(cfg.get(\"redis.protocol\"));\nJedisClientConfig config = DefaultJedisClientConfig.builder()\n    .protocol(proto == null ? RedisProtocol.RESP3 : proto)\n    .build();","handlingStrategy":"validation","validationCode":"RedisProtocol proto = config.getProtocol();\nif (proto != RedisProtocol.RESP2 && proto != RedisProtocol.RESP3) {\n  throw new IllegalArgumentException(\"protocol must be RESP2 or RESP3, got: \" + proto);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only reference the RedisProtocol enum constants shipped by your Jedis version.","Guard string-to-enum config parsing with a whitelist (RESP2/RESP3).","Let the library default the protocol unless you specifically need RESP2/RESP3."],"tags":["configuration","handshake","resp3","protocol","invalid-enum"],"backgroundTag":"invalid-enum-value","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"}