{"record":{"id":"9c1ca77fc02c9b0a","repo":"redis/jedis","slug":"unknown-protocol-version","errorCode":null,"errorMessage":"Unknown protocol version: ","messagePattern":"Unknown protocol version: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/RedisProtocol.java","lineNumber":48,"sourceCode":"  private RedisProtocol(String ver) {\n    this.version = ver;\n  }\n\n  public String version() {\n    return version;\n  }\n\n  /**\n   * Returns the RedisProtocol enum value corresponding to the given protocol version number.\n   * @param proto the protocol version number (2 or 3)\n   * @return the corresponding RedisProtocol enum value\n   * @throws JedisProtocolNotSupportedException if the protocol version is not recognized\n   */\n  public static RedisProtocol from(Long proto) {\n    if (proto == null) return null;\n    if (proto == 2) return RESP2;\n    if (proto == 3) return RESP3;\n    throw new IllegalArgumentException(\"Unknown protocol version: \" + proto);\n  }\n\n  public static RedisProtocol orServerDefault(RedisProtocol proto) {\n    return (proto == null) ? REDIS_SERVER_DEFAULT_PROTO : proto;\n  }\n}\n","sourceCodeStart":30,"sourceCodeEnd":55,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/RedisProtocol.java#L30-L55","documentation":"RedisProtocol.from(Long) maps the HELLO reply's protocol version number to the RESP2/RESP3 enum. Only 2 and 3 are recognized; any other numeric value throws IllegalArgumentException with 'Unknown protocol version: N'. This happens when the server reports a protocol version the client does not support.","triggerScenarios":"Calling RedisProtocol.from() with a Long other than 2 or 3 — e.g. parsing a HELLO response that returned proto 4 (hypothetical future server), or passing a hand-built/mis-parsed value.","commonSituations":"Connecting to a newer/nonstandard Redis-compatible server advertising an unknown protocol version; proxy or middleware altering HELLO output; unit tests feeding raw protocol numbers.","solutions":["Upgrade jedis to a version that recognizes the server's protocol version.","Configure the server (or connection protocol option) to use RESP2 or RESP3, e.g. HELLO 2 or protocol 2.","Validate/normalize the proto value before calling from(), catching IllegalArgumentException to fall back to a supported protocol."],"exampleFix":"// before\nRedisProtocol proto = RedisProtocol.from(helloProto);\n\n// after\nRedisProtocol proto;\ntry {\n  proto = RedisProtocol.from(helloProto);\n} catch (IllegalArgumentException e) {\n  proto = RedisProtocol.RESP2; // safe fallback\n}","handlingStrategy":"try-catch","validationCode":"if (proto == null || (proto != 2 && proto != 3)) {\n  proto = 2L; // default to RESP2 before mapping\n}\nRedisProtocol p = RedisProtocol.from(proto);","typeGuard":"boolean isSupportedProtocol(Long proto) { return proto != null && (proto == 2 || proto == 3); }","tryCatchPattern":"try {\n  protocol = RedisProtocol.from(serverProto);\n} catch (IllegalArgumentException e) {\n  protocol = RedisProtocol.RESP2;\n}","preventionTips":["Pin the connection protocol to 2 or 3 in client/server configuration.","Keep jedis up to date when connecting to newer servers.","Validate HELLO output when going through proxies."],"tags":["protocol","resp","invalid-enum-value"],"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"}