{"record":{"id":"428458800b28ef2f","repo":"provectus/kafka-ui","slug":"application-config-isn-t-valid-two-clusters-can-t","errorCode":null,"errorMessage":"Application config isn't valid. Two clusters can't have the same name","messagePattern":"Application config isn't valid\\. Two clusters can't have the same name","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/config/ClustersProperties.java","lineNumber":216,"sourceCode":"    return flattened;\n  }\n\n  private void validateClusterNames() {\n    // if only one cluster provided it is ok not to set name\n    if (clusters.size() == 1 && !StringUtils.hasText(clusters.get(0).getName())) {\n      clusters.get(0).setName(\"Default\");\n      return;\n    }\n\n    Set<String> clusterNames = new HashSet<>();\n    for (Cluster clusterProperties : clusters) {\n      if (!StringUtils.hasText(clusterProperties.getName())) {\n        throw new IllegalStateException(\n            \"Application config isn't valid. \"\n                + \"Cluster names should be provided in case of multiple clusters present\");\n      }\n      if (!clusterNames.add(clusterProperties.getName())) {\n        throw new IllegalStateException(\n            \"Application config isn't valid. Two clusters can't have the same name\");\n      }\n    }\n  }\n}\n","sourceCodeStart":198,"sourceCodeEnd":222,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/config/ClustersProperties.java#L198-L222","documentation":"validateClusterNames rejects duplicate cluster names: it collects each cluster's `name` into a Set, and if Set.add returns false (name already seen) it throws IllegalStateException. Kafka UI identifies clusters by name in URLs and API paths, so duplicates are ambiguous and the app refuses to start.","triggerScenarios":"Application startup when two or more entries under kafka.clusters share the exact same `name` value.","commonSituations":"Copy-pasting an existing cluster block to add a new environment and forgetting to change the name; environment-variable templating that renders the same name for all clusters; merging config files that both define a cluster named e.g. 'dev'.","solutions":["Give each kafka.clusters entry a distinct `name` value","Search your config for duplicated `name:` values under kafka.clusters","If names come from env vars, ensure each environment supplies a different CLUSTER_NAME"],"exampleFix":"// before\nkafka:\n  clusters:\n    - name: prod\n      bootstrapServers: broker1:9092\n    - name: prod\n      bootstrapServers: broker2:9092\n// after\nkafka:\n  clusters:\n    - name: prod-eu\n      bootstrapServers: broker1:9092\n    - name: prod-us\n      bootstrapServers: broker2:9092","handlingStrategy":"validation","validationCode":"names = [c.get('name') for c in config['kafka']['clusters']]\nif len(names) != len(set(names)):\n    dupes = {n for n in names if names.count(n) > 1}\n    raise ValueError(f'Duplicate cluster names: {dupes}')","typeGuard":null,"tryCatchPattern":"try:\n    app = buildApp(config)\nexcept IllegalStateException as e:\n    log.error('Duplicate cluster names in config: {}', e.message)\n    raise SystemExit(1)","preventionTips":["Copy-paste checklist: change name whenever duplicating a cluster block","Generate names from environment identifiers rather than hardcoding","Add a uniqueness assertion in your config test suite"],"tags":["configuration","startup","kafka","spring"],"backgroundTag":"conflicting-config-options","analyzedSha":"83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7","analyzedAt":"2026-09-08T04:35:39.002Z","contentChangedAt":"2026-09-08T04:35:39.002Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}