redis/jedis · error · JedisValidationException

DatabaseClientConfigs are required for…

Error message

DatabaseClientConfigs are required for MultiDbConnectionProvider

What it means

The MultiDbConfig array constructor validates that a non-null, non-empty array of DatabaseConfig entries is supplied; the multi-db provider cannot operate with zero databases. Violating this throws JedisValidationException.

Solutions

  1. Provide at least one DatabaseConfig entry before constructing MultiDbConfig
  2. Check the source of the array (file/env parsing) to see why it resolved to null/empty
  3. Prefer the Builder API, which collects database configs incrementally

Example fix

// before
DatabaseConfig[] cfgs = loadFromEnv(); // may be empty
MultiDbConfig config = new MultiDbConfig(cfgs); // throws when empty
// after
if (cfgs == null || cfgs.length == 0) {
  throw new IllegalStateException("At least one database config is required");
}
MultiDbConfig config = new MultiDbConfig(cfgs);
Defensive patterns

Strategy: validation

Validate before calling

if (databaseConfigs == null || databaseConfigs.length == 0) {
  throw new IllegalArgumentException("Provide at least one DatabaseConfig for MultiDbConfig");
}

Type guard

boolean hasDatabases(DatabaseConfig[] cfgs) {
  return cfgs != null && cfgs.length > 0;
}

Prevention

When it happens

Trigger: new MultiDbConfig(null) or new MultiDbConfig(new DatabaseConfig[0]) — passing an empty array straight into the constructor instead of using the Builder.

Common situations: Programmatically building the config array (e.g. from a properties file) where the list ended up empty; refactoring from the Builder (which enforces its own checks) to the raw constructor; YAML/JSON parsing yielding an empty databases section.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/redis/clients/jedis/MultiDbConfig.java:678

   * @see #getInitializationPolicy()
   */
  private InitializationPolicy initializationPolicy;

  /**
   * Constructs a new MultiDbConfig with the specified database configurations.
   * <p>
   * This constructor validates that at least one database configuration is provided and that all
   * configurations are non-null. Use the {@link Builder} class for more convenient configuration
   * with default values.
   * </p>
   * @param databaseConfigs array of database configurations defining the available Redis endpoints
   * @throws JedisValidationException if databaseConfigs is null or empty
   * @throws IllegalArgumentException if any database configuration is null
   * @see Builder#Builder(DatabaseConfig[])
   */
  public MultiDbConfig(DatabaseConfig[] databaseConfigs) {

    if (databaseConfigs == null || databaseConfigs.length < 1) throw new JedisValidationException(
        "DatabaseClientConfigs are required for MultiDbConnectionProvider");

    for (DatabaseConfig databaseConfig : databaseConfigs) {
      if (databaseConfig == null)
        throw new IllegalArgumentException("DatabaseClientConfigs must not contain null elements");
    }
    this.databaseConfigs = databaseConfigs;
  }

  /**
   * Returns the array of database configurations defining available Redis endpoints.
   * @return array of database configurations, never null or empty
   */
  public DatabaseConfig[] getDatabaseConfigs() {
    return databaseConfigs;
  }

  /**

View on GitHub (pinned to 6dac31d4c2)