{"record":{"id":"b754fdfe5db8ad1a","repo":"redis/jedis","slug":"provided-endpoint-endpoint-is-not-within-the-c","errorCode":null,"errorMessage":"Provided endpoint: ${endpoint} is not within the configured endpoints. Please use one from the configuration","messagePattern":"Provided endpoint: (.+?) is not within the configured endpoints\\. Please use one from the configuration","errorType":"validation","errorClass":"JedisValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java","lineNumber":674,"sourceCode":"    }\n  }\n\n  /**\n   * Returns the set of all configured endpoints.\n   * @return the set of all configured endpoints\n   */\n  public Set<Endpoint> getEndpoints() {\n    return new HashSet<>(databaseMap.keySet());\n  }\n\n  public void setActiveDatabase(Endpoint endpoint) {\n    if (endpoint == null) {\n      throw new JedisValidationException(\n          \"Provided endpoint is null. Please use one from the configuration\");\n    }\n    Database database = databaseMap.get(endpoint);\n    if (database == null) {\n      throw new JedisValidationException(\"Provided endpoint: \" + endpoint + \" is not within \"\n          + \"the configured endpoints. Please use one from the configuration\");\n    }\n    if (setActiveDatabase(database, true)) {\n      onDatabaseSwitch(SwitchReason.FORCED, endpoint, database);\n    }\n  }\n\n  public void forceActiveDatabase(Endpoint endpoint, long forcedActiveDuration) {\n    Database database = databaseMap.get(endpoint);\n\n    if (database == null) {\n      throw new JedisValidationException(\"Provided endpoint: \" + endpoint + \" is not within \"\n          + \"the configured endpoints. Please use one from the configuration\");\n    }\n\n    database.clearGracePeriod();\n    if (!database.isHealthy()) {\n      throw new JedisValidationException(\"Provided endpoint: \" + endpoint","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java#L656-L692","documentation":"MultiDbConnectionProvider.setActiveDatabase() looks up the Database registered for the given Endpoint in databaseMap. When the endpoint is not one of the endpoints supplied at configuration time the lookup returns null and this JedisValidationException is thrown. The provider only routes to endpoints that were configured in MultiDbConfig; arbitrary endpoints cannot be added at switch time.","triggerScenarios":"Calling setActiveDatabase(endpoint) (directly or via forceActiveDatabase or the database-switch cache flows) with an Endpoint object that was never added to the MultiDbConfig used to build the provider.","commonSituations":"Typo or stale copy of the endpoint (different port, scheme, or hostname than configured), constructing a new Endpoint instance instead of reusing one from getEndpoints() if Endpoint does not compare by value, or config changed (endpoint removed) while an old reference is still in use.","solutions":["Use an Endpoint returned by provider.getEndpoints() (or stored from your MultiDbConfig) rather than a newly constructed one","Verify the endpoint's host/port/scheme exactly matches an entry in MultiDbConfig","Rebuild or update the provider's configuration if the endpoint is legitimately new and should be routable","Catch JedisValidationException and fall back to a known-configured endpoint"],"exampleFix":"// before\nprovider.setActiveDatabase(new HostAndPort(\"localhost\", 6380)); // not from config\n\n// after\nSet<Endpoint> endpoints = provider.getEndpoints();\nEndpoint target = endpoints.stream()\n    .filter(e -> e.toString().contains(\"6380\"))\n    .findFirst()\n    .orElseThrow(() -> new IllegalStateException(\"6380 not configured\"));\nprovider.setActiveDatabase(target);","handlingStrategy":"validation","validationCode":"Set<Endpoint> known = provider.getEndpoints();\nif (endpoint == null || !known.contains(endpoint)) {\n  throw new IllegalArgumentException(endpoint + \" not in configured endpoints \" + known);\n}\nprovider.setActiveDatabase(endpoint);","typeGuard":"boolean isConfigured(Endpoint e, MultiDbConnectionProvider p) {\n  return e != null && p.getEndpoints().contains(e);\n}","tryCatchPattern":"try {\n  provider.setActiveDatabase(endpoint);\n} catch (JedisValidationException e) {\n  log.warn(\"Endpoint {} not configured; staying on current database\", endpoint, e);\n}","preventionTips":["Store configured endpoints once and reuse those references everywhere","Keep Endpoint equality in mind: compare host/port exactly as configured","Update config and callers together when adding/removing endpoints"],"tags":["jedis","validation","multidb","unknown-endpoint"],"backgroundTag":"invalid-argument-value","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"}