redis/jedis · error · IllegalArgumentException

Password not provided in uri.

Error message

Password not provided in uri.

What it means

getPassword(URI) parses the URI's userInfo and expects the form `password` or `user:password`. When userInfo exists but contains no ':' separator (after splitting with limit 2), the library concludes no password portion was provided and throws IllegalArgumentException. A URI with no userInfo at all returns null instead.

Solutions

  1. Rewrite the URI userInfo to include the password after a colon: `redis://default:YOURPASS@host:6379/`.
  2. URL-encode special characters in both user and password (e.g. '@' -> %40) so splitting on ':' works as expected.
  3. If your URI genuinely has no password, don't call getPassword — handle the null case from a null userInfo instead, or use JedisClientConfig setters.

Example fix

// before
URI uri = URI.create("redis://secretpass@localhost:6379/2");
String pass = JedisURIHelper.getPassword(uri); // throws
// after
URI uri = URI.create("redis://default:secretpass@localhost:6379/2");
String pass = JedisURIHelper.getPassword(uri);
Defensive patterns

Strategy: validation

Validate before calling

static boolean uriHasPassword(URI uri) {
  String ui = uri.getUserInfo();
  return ui != null && ui.contains(":");
}
// call before JedisURIHelper.getPassword(uri)

Try / catch

try {
  String pass = JedisURIHelper.getPassword(uri);
} catch (IllegalArgumentException e) {
  // prompt/rebuild URI with user:password form
}

Prevention

When it happens

Trigger: Passing a URI like `redis://mypassword@host:6379/` (bare token with no colon) to getPassword. Any single-segment userInfo — `redis://user@host`, `redis://token@host` — triggers it, since split(":", 2) yields length 1.

Common situations: Copying connection URIs from providers that URL-encode only the username; ACL-enabled Redis setups where people assume `redis://default@host` carries the password; hand-written URIs missing the `user:password` form.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/acf326e6b80cc2e7. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/util/JedisURIHelper.java:82

    return null;
  }

  /**
   * Extracts the password from the given URI.
   * <p>
   * For details on the URI format and authentication examples, see {@link JedisURIHelper}.
   * </p>
   * @param uri the URI to extract the password from
   * @return the password as a String, or null if {@link URI#getUserInfo()} info is missing
   * @throws IllegalArgumentException if {@link URI#getUserInfo()} is provided but does not contain
   *           a password
   */
  public static String getPassword(URI uri) {
    String userInfo = uri.getUserInfo();
    if (userInfo != null) {
      String[] userAndPassword = userInfo.split(":", 2);
      if (userAndPassword.length < 2) {
        throw new IllegalArgumentException("Password not provided in uri.");
      }
      return userAndPassword[1];
    }
    return null;
  }

  /**
   * Checks if the given URI has a database index component.
   *
   * @param uri the URI to check
   * @return true if the URI has a database index component, false otherwise
   */
  public static boolean hasDbIndex(URI uri) {
    if (uri.getPath() == null || uri.getPath().isEmpty()) {
      return false;
    }

    String[] pathSplit = uri.getPath().split("/", 2);

View on GitHub (pinned to 6dac31d4c2)