{"record":{"id":"187ea02a826d6172","repo":"provectus/kafka-ui","slug":"application-config-isn-t-valid-cluster-names-shou","errorCode":null,"errorMessage":"Application config isn't valid. Cluster names should be provided in case of multiple clusters present","messagePattern":"Application config isn't valid\\. Cluster names should be provided in case of multiple clusters present","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/config/ClustersProperties.java","lineNumber":211,"sourceCode":"        } else {\n          flattened.put(key, v);\n        }\n      });\n    }\n    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":193,"sourceCodeEnd":222,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/config/ClustersProperties.java#L193-L222","documentation":"At application startup, ClustersProperties.validateClusterNames enforces that when more than one Kafka cluster is configured in the `kafka.clusters` list, every cluster entry must have a non-blank `name`. It throws IllegalStateException during config validation (validateAndSetDefaults) so the app fails fast rather than running with ambiguous cluster references.","triggerScenarios":"Spring context startup with kafka.clusters containing 2+ entries and at least one entry without a `name` property (blank, empty, or missing).","commonSituations":"Adding a second cluster to application.yml/properties and forgetting the name because a single anonymous cluster worked before; YAML indentation mistakes leaving `name` unset; generating config from templates that omit name for the first cluster.","solutions":["Add a unique `name` field to every cluster entry under kafka.clusters in your application config","Keep a `name` even for a single cluster so later additions can't break startup","Validate the YAML locally (e.g. run the app with only config loading) before deploying"],"exampleFix":"// before\nkafka:\n  clusters:\n    - bootstrapServers: broker1:9092\n    - bootstrapServers: broker2:9092\n// after\nkafka:\n  clusters:\n    - name: dev\n      bootstrapServers: broker1:9092\n    - name: prod\n      bootstrapServers: broker2:9092","handlingStrategy":"validation","validationCode":"clusters = config['kafka']['clusters']\nif len(clusters) > 1:\n    missing = [i for i, c in enumerate(clusters) if not c.get('name', '').strip()]\n    if missing:\n        raise ValueError(f'clusters missing name at indices: {missing}')","typeGuard":null,"tryCatchPattern":"try:\n    app = buildApp(config)\nexcept IllegalStateException as e:\n    log.error('Cluster config invalid: {}', e.message)\n    raise SystemExit(1)","preventionTips":["Always set a name for every cluster, even with a single cluster","Lint application.yml in CI for required kafka.clusters[].name fields","Use a config schema validator before deploy"],"tags":["configuration","startup","kafka","spring"],"backgroundTag":"missing-required-config-field","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"}