redis/jedis · error · JedisValidationException

Provided endpoint: is not within the configured endpoints…

Error message

Provided endpoint: ${endpoint} is not within the configured endpoints. Please use one from the configuration

What it means

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.

Solutions

  1. Use an Endpoint returned by provider.getEndpoints() (or stored from your MultiDbConfig) rather than a newly constructed one
  2. Verify the endpoint's host/port/scheme exactly matches an entry in MultiDbConfig
  3. Rebuild or update the provider's configuration if the endpoint is legitimately new and should be routable
  4. Catch JedisValidationException and fall back to a known-configured endpoint

Example fix

// before
provider.setActiveDatabase(new HostAndPort("localhost", 6380)); // not from config

// after
Set<Endpoint> endpoints = provider.getEndpoints();
Endpoint target = endpoints.stream()
    .filter(e -> e.toString().contains("6380"))
    .findFirst()
    .orElseThrow(() -> new IllegalStateException("6380 not configured"));
provider.setActiveDatabase(target);
Defensive patterns

Strategy: validation

Validate before calling

Set<Endpoint> known = provider.getEndpoints();
if (endpoint == null || !known.contains(endpoint)) {
  throw new IllegalArgumentException(endpoint + " not in configured endpoints " + known);
}
provider.setActiveDatabase(endpoint);

Type guard

boolean isConfigured(Endpoint e, MultiDbConnectionProvider p) {
  return e != null && p.getEndpoints().contains(e);
}

Try / catch

try {
  provider.setActiveDatabase(endpoint);
} catch (JedisValidationException e) {
  log.warn("Endpoint {} not configured; staying on current database", endpoint, e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java:674

    }
  }

  /**
   * Returns the set of all configured endpoints.
   * @return the set of all configured endpoints
   */
  public Set<Endpoint> getEndpoints() {
    return new HashSet<>(databaseMap.keySet());
  }

  public void setActiveDatabase(Endpoint endpoint) {
    if (endpoint == null) {
      throw new JedisValidationException(
          "Provided endpoint is null. Please use one from the configuration");
    }
    Database database = databaseMap.get(endpoint);
    if (database == null) {
      throw new JedisValidationException("Provided endpoint: " + endpoint + " is not within "
          + "the configured endpoints. Please use one from the configuration");
    }
    if (setActiveDatabase(database, true)) {
      onDatabaseSwitch(SwitchReason.FORCED, endpoint, database);
    }
  }

  public void forceActiveDatabase(Endpoint endpoint, long forcedActiveDuration) {
    Database database = databaseMap.get(endpoint);

    if (database == null) {
      throw new JedisValidationException("Provided endpoint: " + endpoint + " is not within "
          + "the configured endpoints. Please use one from the configuration");
    }

    database.clearGracePeriod();
    if (!database.isHealthy()) {
      throw new JedisValidationException("Provided endpoint: " + endpoint

View on GitHub (pinned to 6dac31d4c2)