redis/jedis · error · JedisValidationException

must not be empty

Error message

 must not be empty

What it means

DriverInfo.validateDriverField throws JedisValidationException when a driver name or version is empty (or only whitespace): the message is "<fieldName> must not be empty" (e.g. "Driver name must not be empty"). CLIENT SETINFO values must be non-empty printable tokens, so blank strings are rejected after the null check.

Solutions

  1. Supply a non-blank value (trim checks in the library mean " " is still rejected).
  2. Validate caller-side with value != null && !value.trim().isEmpty() before registering.
  3. Skip driver registration entirely when the real value is unavailable rather than passing a placeholder blank.

Example fix

// before
builder.addUpstreamDriver(driverName.trim(), version.trim()); // may become ""
// after
if (!driverName.trim().isEmpty() && !version.trim().isEmpty()) {
  builder.addUpstreamDriver(driverName.trim(), version.trim());
}
Defensive patterns

Strategy: validation

Validate before calling

static boolean isBlank(String s) { return s == null || s.trim().isEmpty(); }
if (isBlank(name) || isBlank(version)) { /* fix or skip registration */ }

Type guard

boolean nonBlank(String s) { return s != null && !s.trim().isEmpty(); }

Try / catch

try {
  builder.addUpstreamDriver(name, version);
} catch (JedisValidationException e) {
  log.warn("Blank driver field rejected: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling addUpstreamDriver("", "1.0"), addUpstreamDriver("x", " "), or the single-arg addUpstreamDriver(" "); any DriverInfo.Builder entry whose field trims to empty.

Common situations: Version strings resolved from config files with blank values; driver names built by trimming user input down to nothing; defaults of "" used where null checks pass but emptiness fails.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/redis/clients/jedis/DriverInfo.java:224

    public DriverInfo build() {
      return new DriverInfo(name, upstreamDrivers);
    }
  }

  /**
   * Validates that the value does not contain characters that would violate the format of the Redis
   * CLIENT LIST reply.
   * <p>
   * Only printable ASCII characters (0x21-0x7E, i.e., '!' to '~') are allowed, excluding braces.
   * @param value the value to validate
   * @param fieldName the name of the field for error messages (e.g., "Driver name", "Driver
   *          version")
   * @throws JedisValidationException if the value is empty or contains invalid characters
   * @see <a href="https://redis.io/docs/latest/commands/client-setinfo/">CLIENT SETINFO</a>
   */
  private static void validateDriverField(String value, String fieldName) {
    if (value.trim().isEmpty()) {
      throw new JedisValidationException(fieldName + " must not be empty");
    }

    validateNoInvalidCharacters(value, fieldName);
  }

  /**
   * Validates that the value does not contain characters that would violate the format of the Redis
   * CLIENT LIST reply: non-printable characters, spaces, or brace characters.
   * <p>
   * Only printable ASCII characters (0x21-0x7E, i.e., '!' to '~') are allowed, excluding braces.
   * @param value the value to validate
   * @param fieldName the name of the field for error messages
   * @throws JedisValidationException if the value contains invalid characters
   * @see <a href="https://redis.io/docs/latest/commands/client-setinfo/">CLIENT SETINFO</a>
   */
  private static void validateNoInvalidCharacters(String value, String fieldName) {
    for (int i = 0; i < value.length(); i++) {
      char c = value.charAt(i);

View on GitHub (pinned to 6dac31d4c2)