{"record":{"id":"f7bde28bca2216d3","repo":"redis/jedis","slug":"no-nodes-to-initialize-cluster-slots-cache","errorCode":null,"errorMessage":"No nodes to initialize cluster slots cache.","messagePattern":"No nodes to initialize cluster slots cache\\.","errorType":"exception","errorClass":"JedisClusterOperationException","httpStatus":null,"severity":"critical","filePath":"src/main/java/redis/clients/jedis/providers/ClusterConnectionProvider.java","lineNumber":69,"sourceCode":"    initializeSlotsCache(clusterNodes, clientConfig);\n  }\n\n  public ClusterConnectionProvider(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig,\n      GenericObjectPoolConfig<Connection> poolConfig, Duration topologyRefreshPeriod) {\n    this.cache = new JedisClusterInfoCache(clientConfig, poolConfig, clusterNodes, topologyRefreshPeriod);\n    initializeSlotsCache(clusterNodes, clientConfig);\n  }\n\n  @Experimental\n  public ClusterConnectionProvider(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig, Cache clientSideCache,\n      GenericObjectPoolConfig<Connection> poolConfig, Duration topologyRefreshPeriod) {\n    this.cache = new JedisClusterInfoCache(clientConfig, clientSideCache, poolConfig, clusterNodes, topologyRefreshPeriod);\n    initializeSlotsCache(clusterNodes, clientConfig);\n  }\n\n  private void initializeSlotsCache(Set<HostAndPort> startNodes, JedisClientConfig clientConfig) {\n    if (startNodes.isEmpty()) {\n      throw new JedisClusterOperationException(\"No nodes to initialize cluster slots cache.\");\n    }\n\n    ArrayList<HostAndPort> startNodeList = new ArrayList<>(startNodes);\n    Collections.shuffle(startNodeList);\n\n    JedisException firstException = null;\n    for (HostAndPort hostAndPort : startNodeList) {\n      try (Connection jedis = new Connection(hostAndPort, clientConfig)) {\n        cache.discoverClusterNodesAndSlots(jedis);\n        return;\n      } catch (JedisException e) {\n        if (firstException == null) {\n          firstException = e;\n        }\n        // try next nodes\n      }\n    }\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/providers/ClusterConnectionProvider.java#L51-L87","documentation":"ClusterConnectionProvider.initializeSlotsCache() refuses to start the cluster slot cache when the supplied set of seed nodes is empty, throwing JedisClusterOperationException. Without at least one seed node, Jedis cannot discover the cluster topology or slot mapping.","triggerScenarios":"Creating a JedisCluster / ClusterConnectionProvider with an empty Set<HostAndPort> for clusterNodes, or with a host/port set that was filtered to nothing.","commonSituations":"Reading cluster node addresses from config/env that failed to parse; building the node set programmatically with a filter that removed all entries; constructing the client before config loading finished.","solutions":["Pass at least one valid cluster seed node, e.g. new HashSet<>(Set.of(new HostAndPort(\"127.0.0.1\", 7000))).","Fix the config/env parsing that yields an empty node list and log/fail early if the list is empty.","Verify cluster node host/port values are populated before constructing the client."],"exampleFix":"// before\nSet<HostAndPort> nodes = parseNodes(config); // may be empty\nJedisCluster cluster = new JedisCluster(nodes);\n// after\nSet<HostAndPort> nodes = parseNodes(config);\nif (nodes.isEmpty()) throw new IllegalStateException(\"No cluster nodes configured\");\nJedisCluster cluster = new JedisCluster(nodes);","handlingStrategy":"validation","validationCode":"if (nodes == null || nodes.isEmpty()) throw new IllegalStateException(\"At least one cluster seed node is required\");\nJedisCluster cluster = new JedisCluster(nodes, clientConfig);","typeGuard":"boolean hasSeedNodes(Set<HostAndPort> nodes) { return nodes != null && !nodes.isEmpty(); }","tryCatchPattern":"try {\n  cluster = new JedisCluster(nodes);\n} catch (JedisClusterOperationException e) {\n  log.error(\"No cluster seed nodes configured\", e);\n  throw new IllegalStateException(\"Cluster client requires seed nodes\", e);\n}","preventionTips":["Validate the parsed node list is non-empty before constructing the client.","Fail fast at config-load time with a clear message.","Keep at least 2-3 seed nodes for resilience."],"tags":["jedis","cluster","configuration","redis"],"backgroundTag":"empty-required-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"}