{"record":{"id":"bbddb220f8535b5f","repo":"apache/kafka","slug":"you-must-set-either-bootstrap-servers-or-bootstrap","errorCode":null,"errorMessage":"You must set either bootstrap.servers or bootstrap.controllers","messagePattern":"You must set either bootstrap\\.servers or bootstrap\\.controllers","errorType":"validation","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java","lineNumber":544,"sourceCode":"     * Validates that exactly one of bootstrap.servers or bootstrap.controllers is configured.\n     *\n     * @param config The admin client configuration\n     * @return true if using bootstrap.controllers, false if using bootstrap.servers\n     * @throws ConfigException if both or neither bootstrap configurations are set\n     */\n    static boolean determineBootstrapType(AdminClientConfig config) {\n        List<String> bootstrapServers = config.getList(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG);\n        if (bootstrapServers == null) {\n            bootstrapServers = Collections.emptyList();\n        }\n        List<String> controllerServers = config.getList(AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG);\n        if (controllerServers == null) {\n            controllerServers = Collections.emptyList();\n        }\n\n        if (bootstrapServers.isEmpty()) {\n            if (controllerServers.isEmpty()) {\n                throw new ConfigException(\"You must set either \" +\n                    CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG + \" or \" +\n                    AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG);\n            } else {\n                return true; // Using bootstrap.controllers\n            }\n        } else {\n            if (controllerServers.isEmpty()) {\n                return false; // Using bootstrap.servers\n            } else {\n                throw new ConfigException(\"You cannot set both \" +\n                    CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG + \" and \" +\n                    AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG);\n            }\n        }\n    }\n\n    static KafkaAdminClient createInternal(AdminClientConfig config, TimeoutProcessorFactory timeoutProcessorFactory) {\n        return createInternal(config, timeoutProcessorFactory, null);","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java#L526-L562","documentation":"Thrown by KafkaAdminClient.determineBootstrapType (a ConfigException) when neither bootstrap.servers nor bootstrap.controllers is configured. The Admin client needs at least one entry point to contact the cluster.","triggerScenarios":"Building an Admin with a Properties/Map that omits both CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG and AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG. Setting the key to an empty string. Reading config from a file where the property was commented out.","commonSituations":"Copy-pasting an Admin config block and dropping the bootstrap line; property-name typo (e.g. bootstrap.server without the s); env-var substitution that resolved to empty; migrating from bootstrap.servers to bootstrap.controllers but forgetting to actually set the new key.","solutions":["Set AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG to a comma-separated host:port list (most common).","Or set AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG when talking directly to KRaft controllers.","Log the resolved config map in dev to catch empty/typo'd keys early."],"exampleFix":"// before\nMap<String, Object> cfg = new HashMap<>();\n// bootstrap.servers missing\nAdmin.create(cfg);\n\n// after\nMap<String, Object> cfg = new HashMap<>();\ncfg.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, \"broker1:9092,broker2:9092\");\nAdmin.create(cfg);","handlingStrategy":"validation","validationCode":"String servers = (String) props.get(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG);\nString controllers = (String) props.get(AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG);\nif ((servers == null || servers.isEmpty()) && (controllers == null || controllers.isEmpty())) {\n    throw new IllegalStateException(\"Configure bootstrap.servers or bootstrap.controllers\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Admin.create(props);\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"bootstrap\")) { /* fix config, retry */ }\n}","preventionTips":["Always set one bootstrap property in shared config templates.","Log the resolved config in dev to catch empty/typo'd keys."],"tags":["kafka-admin","configuration","bootstrap","client-setup"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}