{"record":{"id":"9691c5afd4d19a12","repo":"redis/jedis","slug":"provided-endpoint-is-null-please-use-one-from-the","errorCode":null,"errorMessage":"Provided endpoint is null. Please use one from the configuration","messagePattern":"Provided endpoint is null\\. 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":669,"sourceCode":"      // event publishing\n      if (State.FORCED_OPEN.equals(originalState)) circuitBreaker.transitionToForcedOpenState();\n\n      throw new JedisValidationException(circuitBreaker.getName()\n          + \" failed to connect. Please check configuration and try again.\", e);\n    }\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\");","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java#L651-L687","documentation":"MultiDbConnectionProvider.setActiveDatabase() throws JedisValidationException when the Endpoint argument is null. The provider switches traffic between multiple Redis databases keyed by Endpoint objects, so a null endpoint has no meaning and would cause a NullPointerException later. The library fails fast with this explicit validation error instead.","triggerScenarios":"Calling setActiveDatabase(null) directly, or indirectly via forceActiveDatabase(null) or the cache-flushing database-switch flows (databaseSwitch_flushesClientSideCache / databaseSwitch_notFlushesClientSideCache) when an upstream variable holding the endpoint is null.","commonSituations":"A config property or map lookup for the endpoint returned null (e.g. MultiDbConfig not populated, wrong key), a deserialized endpoint field was never set, or a helper method returns Optional#get on an empty value.","solutions":["Pass a non-null Endpoint obtained from the configured endpoints (e.g. from MultiDbConnectionProvider.getEndpoints() or your MultiDbConfig)","Check for null before calling setActiveDatabase and log/throw a clearer application-level error","Fix whatever produces the null endpoint: verify the configuration actually contains the endpoint and that field initialization/deserialization ran","Catch JedisValidationException around the call as a last-resort guard"],"exampleFix":"// before\nprovider.setActiveDatabase(endpointFromConfig()); // may be null\n\n// after\nEndpoint endpoint = endpointFromConfig();\nif (endpoint == null) {\n  throw new IllegalStateException(\"No endpoint configured for failover target\");\n}\nprovider.setActiveDatabase(endpoint);","handlingStrategy":"validation","validationCode":"if (endpoint == null) {\n  throw new IllegalArgumentException(\"endpoint must be one of \" + provider.getEndpoints());\n}\nprovider.setActiveDatabase(endpoint);","typeGuard":"boolean isValidEndpoint(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.error(\"Null/invalid endpoint passed to setActiveDatabase: {}\", e.getMessage());\n}","preventionTips":["Source Endpoint objects from getEndpoints() or MultiDbConfig, never build them ad hoc","Null-check configuration-derived values before failover logic runs","Fail fast at application startup if no endpoints are configured"],"tags":["jedis","null-argument","validation","multidb"],"backgroundTag":"null-argument","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"}