{"record":{"id":"694e7b9868ef5929","repo":"redis/jedis","slug":"protocol-must-not-be-null-694e7b","errorCode":null,"errorMessage":"protocol must not be null","messagePattern":"protocol must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/Connection.java","lineNumber":1071,"sourceCode":"   *   <li>If {@code credentials} is provided but the password is {@code null}, no authentication\n   *       is performed.</li>\n   * </ul>\n   *\n   * <p>Note:</p>\n   * <ul>\n   *   <li>{@code HELLO} is available only in Redis 6.0 and newer.</li>\n   *   <li>The command both negotiates the protocol version (RESP2/RESP3) and returns\n   *       server metadata.</li>\n   * </ul>\n   *\n   * @param protocol the requested RESP protocol version (must not be {@code null})\n   * @param credentials optional credentials used for authentication (may be {@code null})\n   * @return the parsed {@code HELLO} response containing server metadata\n   * @throws IllegalArgumentException if {@code protocol} is {@code null}\n   */\n  HelloResult hello(RedisProtocol protocol, RedisCredentials credentials) {\n    if (protocol == null) {\n      throw new IllegalArgumentException(\"protocol must not be null\");\n    }\n\n    byte[] rawPass = null;\n    try {\n      byte[][] args;\n      byte[] versionRaw = encode(protocol.version());\n      if (credentials != null && credentials.getPassword() != null) {\n        String user = credentials.getUser();\n        if (user == null) {\n          user = \"default\";\n        }\n        rawPass = encodeToBytes(credentials.getPassword());\n        args = new byte[][] { versionRaw, Keyword.AUTH.getRaw(), encode(user), rawPass };\n      } else {\n        args = new byte[][] { versionRaw };\n      }\n      return new HelloResult(hello(args));\n    } finally {","sourceCodeStart":1053,"sourceCodeEnd":1089,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/Connection.java#L1053-L1089","documentation":"Connection.hello() throws IllegalArgumentException when the RedisProtocol argument is null. The HELLO command requires a protocol version (RESP2 or RESP3), so the client refuses to send a HELLO without knowing which version to negotiate.","triggerScenarios":"Calling connection.hello(null, credentials) or hello(null, null) directly; passing a null RedisProtocol when building a Connection or performing handshake/auth that delegates to hello.","commonSituations":"Custom connection or provider code that resolves the protocol from a config object which was left unset (DefaultJedisClientConfig without a protocol); hand-rolled authentication flows calling the low-level hello API; refactors that made protocol resolution return null on older servers.","solutions":["Pass an explicit RedisProtocol.RESP2 or RedisProtocol.RESP3 to hello()","Set the protocol in DefaultJedisClientConfig via .protocol(RedisProtocol.RESP3) before building the connection","If the server version is unknown, default to RESP2 (available since Redis 6) instead of null"],"exampleFix":"// before\nHelloResult r = connection.hello(null, creds);\n// after\nHelloResult r = connection.hello(RedisProtocol.RESP3, creds);","handlingStrategy":"validation","validationCode":"if (protocol == null) {\n  throw new IllegalArgumentException(\"protocol must be RESP2 or RESP3 before calling hello()\");\n}\nHelloResult r = connection.hello(protocol, creds);","typeGuard":"boolean isValidProtocol(RedisProtocol p) { return p == RedisProtocol.RESP2 || p == RedisProtocol.RESP3; }","tryCatchPattern":"try {\n  connection.hello(protocol, creds);\n} catch (IllegalArgumentException e) {\n  // protocol was null; set a default and retry\n}","preventionTips":["Always set .protocol(RedisProtocol.RESP3) in DefaultJedisClientConfig when using HELLO-based auth","Never pass config-derived protocol values straight into hello() without a null check","Default to RESP2 when the server version is unknown"],"tags":["java","jedis","hello-command","protocol-negotiation","null-argument"],"backgroundTag":"null-argument","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"}