{"record":{"id":"d6df26f0d1047772","repo":"redis/jedis","slug":"at-least-one-endpoint-must-be-specified","errorCode":null,"errorMessage":"At least one endpoint must be specified","messagePattern":"At least one endpoint must be specified","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/builders/MultiDbClientBuilder.java","lineNumber":116,"sourceCode":"   * @param listener the database switch event listener\n   * @return this builder\n   */\n  public MultiDbClientBuilder<C> databaseSwitchListener(Consumer<DatabaseSwitchEvent> listener) {\n    this.databaseSwitchListener = listener;\n    return this;\n  }\n\n  @Override\n  protected MultiDbClientBuilder<C> self() {\n    return this;\n  }\n\n  @Override\n  protected ConnectionProvider createDefaultConnectionProvider() {\n\n    if (this.multiDbConfig == null || this.multiDbConfig.getDatabaseConfigs() == null\n        || this.multiDbConfig.getDatabaseConfigs().length < 1) {\n      throw new IllegalArgumentException(\"At least one endpoint must be specified\");\n    }\n\n    // Create the multi-database connection provider\n    MultiDbConnectionProvider provider = new MultiDbConnectionProvider(multiDbConfig, cache);\n\n    // Set database switch listener if provided\n    if (this.databaseSwitchListener != null) {\n      provider.setDatabaseSwitchListener(this.databaseSwitchListener);\n    }\n\n    return provider;\n  }\n\n  @Override\n  protected CommandExecutor createDefaultCommandExecutor() {\n    // For multi-db clients, we always use MultiDbCommandExecutor\n    return new MultiDbCommandExecutor((MultiDbConnectionProvider) this.connectionProvider);\n  }","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/builders/MultiDbClientBuilder.java#L98-L134","documentation":"MultiDbClientBuilder builds a MultiDbClient backed by MultiDbConnectionProvider, which needs a list of database endpoint configurations (primary/failover databases). createDefaultConnectionProvider() throws this IllegalArgumentException when multiDbConfig is null, has null database configs, or an empty array, because the provider has nothing to connect or fail over to.","triggerScenarios":"Building a MultiDbClient without calling .multiDb(MultiDbConfig) or with a MultiDbConfig whose databaseConfigs array is empty (no .database(...) endpoints added), then build() reaching createDefaultConnectionProvider().","commonSituations":"Forgetting to add any database endpoint to the MultiDbConfig; conditionally adding endpoints from config and ending up with an empty array; constructing the builder without the multiDbConfig field set.","solutions":["Add at least one endpoint via MultiDbConfig.builder().database(...) (and optionally additional failover databases) before build().","Verify you passed the MultiDbConfig to the client builder with .multiDb(config).","Validate config-driven endpoint lists for emptiness at application startup."],"exampleFix":"// before\nMultiDbClient client = MultiDbClient.builder()\n    .multiDb(MultiDbConfig.builder().build()) // no databases\n    .build(); // throws\n// after\nMultiDbClient client = MultiDbClient.builder()\n    .multiDb(MultiDbConfig.builder()\n        .database(DatabaseConfig.builder(HostAndPort.of(\"localhost\", 6379)).connectionPoolConfig(poolCfg).build())\n        .build())\n    .build();","handlingStrategy":"validation","validationCode":"if (config == null || config.getDatabaseConfigs() == null || config.getDatabaseConfigs().length < 1) {\n  throw new IllegalArgumentException(\"MultiDbConfig requires at least one database endpoint\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  client = MultiDbClient.builder().multiDb(config).build();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"At least one endpoint\")) {\n    throw new ConfigurationException(\"no multi-db endpoints configured\", e);\n  }\n  throw e;\n}","preventionTips":["Construct MultiDbConfig with its builder and always add at least the primary database.","Validate endpoint lists from configuration before creating the config.","Unit-test client construction with the real application config to catch empty-endpoint cases."],"tags":["jedis","multi-db","builder","configuration","missing-endpoints"],"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"}