{"record":{"id":"ab5a92bb1447a6e8","repo":"redis/jedis","slug":"databaseclientconfigs-are-required-for-multidbconn","errorCode":null,"errorMessage":"DatabaseClientConfigs are required for MultiDbConnectionProvider","messagePattern":"DatabaseClientConfigs are required for MultiDbConnectionProvider","errorType":"validation","errorClass":"JedisValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/MultiDbConfig.java","lineNumber":678,"sourceCode":"   * @see #getInitializationPolicy()\n   */\n  private InitializationPolicy initializationPolicy;\n\n  /**\n   * Constructs a new MultiDbConfig with the specified database configurations.\n   * <p>\n   * This constructor validates that at least one database configuration is provided and that all\n   * configurations are non-null. Use the {@link Builder} class for more convenient configuration\n   * with default values.\n   * </p>\n   * @param databaseConfigs array of database configurations defining the available Redis endpoints\n   * @throws JedisValidationException if databaseConfigs is null or empty\n   * @throws IllegalArgumentException if any database configuration is null\n   * @see Builder#Builder(DatabaseConfig[])\n   */\n  public MultiDbConfig(DatabaseConfig[] databaseConfigs) {\n\n    if (databaseConfigs == null || databaseConfigs.length < 1) throw new JedisValidationException(\n        \"DatabaseClientConfigs are required for MultiDbConnectionProvider\");\n\n    for (DatabaseConfig databaseConfig : databaseConfigs) {\n      if (databaseConfig == null)\n        throw new IllegalArgumentException(\"DatabaseClientConfigs must not contain null elements\");\n    }\n    this.databaseConfigs = databaseConfigs;\n  }\n\n  /**\n   * Returns the array of database configurations defining available Redis endpoints.\n   * @return array of database configurations, never null or empty\n   */\n  public DatabaseConfig[] getDatabaseConfigs() {\n    return databaseConfigs;\n  }\n\n  /**","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/MultiDbConfig.java#L660-L696","documentation":"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.","triggerScenarios":"new MultiDbConfig(null) or new MultiDbConfig(new DatabaseConfig[0]) — passing an empty array straight into the constructor instead of using the Builder.","commonSituations":"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.","solutions":["Provide at least one DatabaseConfig entry before constructing MultiDbConfig","Check the source of the array (file/env parsing) to see why it resolved to null/empty","Prefer the Builder API, which collects database configs incrementally"],"exampleFix":"// before\nDatabaseConfig[] cfgs = loadFromEnv(); // may be empty\nMultiDbConfig config = new MultiDbConfig(cfgs); // throws when empty\n// after\nif (cfgs == null || cfgs.length == 0) {\n  throw new IllegalStateException(\"At least one database config is required\");\n}\nMultiDbConfig config = new MultiDbConfig(cfgs);","handlingStrategy":"validation","validationCode":"if (databaseConfigs == null || databaseConfigs.length == 0) {\n  throw new IllegalArgumentException(\"Provide at least one DatabaseConfig for MultiDbConfig\");\n}","typeGuard":"boolean hasDatabases(DatabaseConfig[] cfgs) {\n  return cfgs != null && cfgs.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Validate the config source (file/env) yields a non-empty database list","Prefer the Builder API to assemble database configs incrementally","Fail fast in your own config loader before instantiating client objects"],"tags":["redis","multi-db","config-validation","empty-collection"],"backgroundTag":"missing-required-config-field","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"}