{"record":{"id":"e8c9c0f469571e7c","repo":"t8y2/dbx","slug":"zookeeper-server-list-is-empty","errorCode":null,"errorMessage":"ZooKeeper server list is empty","messagePattern":"ZooKeeper server list is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/zookeeper_protocol.go","lineNumber":93,"sourceCode":"\toptions.QOP = \"auth\"\n\toptions.AuthorizationID = \"\"\n\toptions.ServiceHost = \"\"\n\toptions.CanonicalizeHost = config.ZooKeeperKerberos.CanonicalHostname\n\toptions.ServerName = config.ZooKeeperKerberos.ServerPrincipal\n\tif options.ServerName == \"\" && config.ZooKeeperKerberos.Realm != \"\" {\n\t\toptions.ServerName = service + \"/_HOST@\" + config.ZooKeeperKerberos.Realm\n\t}\n\treturn service, options\n}\n\nfunc connectKerberosZooKeeper(\n\tservers []string,\n\ttimeout time.Duration,\n\ttlsConfig *tls.Config,\n\tconfig connectionConfig,\n) (zooKeeperClient, <-chan zk.Event, error) {\n\tif len(servers) == 0 {\n\t\treturn nil, nil, errors.New(\"ZooKeeper server list is empty\")\n\t}\n\tif !config.Kerberos.Enabled {\n\t\treturn nil, nil, errors.New(\"ZooKeeper Kerberos SASL requires Hive Kerberos credentials\")\n\t}\n\tordered := append([]string(nil), servers...)\n\tshuffleZooKeeperServers(ordered)\n\tvar failures []string\n\tfor _, address := range ordered {\n\t\thost, _, err := net.SplitHostPort(address)\n\t\tif err != nil {\n\t\t\tfailures = append(failures, fmt.Sprintf(\"%s: %v\", address, err))\n\t\t\tcontinue\n\t\t}\n\t\tconnection, err := dialZooKeeperConnection(address, timeout, tlsConfig)\n\t\tif err != nil {\n\t\t\tfailures = append(failures, fmt.Sprintf(\"%s: %v\", address, err))\n\t\t\tcontinue\n\t\t}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/zookeeper_protocol.go#L75-L111","documentation":"connectKerberosZooKeeper validates the server list up front and returns this error when the servers slice has zero entries. Establishing a ZooKeeper connection is impossible without at least one host:port, so the library fails fast before attempting Kerberos setup or shuffling.","triggerScenarios":"Calling connectKerberosZooKeeper (or the connect path it backs) with servers == nil or an empty slice — typically from an empty/whitespace-only zookeeper.quorum config or a config parse that produced no hosts.","commonSituations":"Config file missing the ZooKeeper hosts key; environment variable like ZOOKEEPER_QUORUM unset or empty; splitting a comma-separated quorum string that was empty resulting in a zero-length slice.","solutions":["Populate the ZooKeeper server list (host:port[,host:port...]) in the connection config","Validate at startup that the parsed server list is non-empty and fail with an application-level message","Fix the config/env parsing that produced an empty list (trim, handle missing env vars)","Point to reachable ensemble members if hosts were intentionally left blank in dev"],"exampleFix":"// before\nconn, _, err := connectKerberosZooKeeper(strings.Split(os.Getenv(\"ZK_QUORUM\"), \",\"), timeout, tls, cfg)\n// after\nraw := strings.TrimSpace(os.Getenv(\"ZK_QUORUM\"))\nif raw == \"\" {\n    return fmt.Errorf(\"ZK_QUORUM is required\")\n}\nconn, _, err := connectKerberosZooKeeper(strings.Split(raw, \",\"), timeout, tls, cfg)","handlingStrategy":"validation","validationCode":"servers := strings.Split(strings.TrimSpace(cfg.ZooKeeperQuorum), \",\")\nif len(servers) == 0 || (len(servers) == 1 && servers[0] == \"\") {\n    return errors.New(\"zookeeper quorum must list at least one host:port\")\n}","typeGuard":null,"tryCatchPattern":"conn, events, err := connectKerberosZooKeeper(servers, timeout, tls, cfg)\nif err != nil && strings.Contains(err.Error(), \"ZooKeeper server list is empty\") {\n    // fail startup with a clear config error\n}","preventionTips":["Require the quorum setting at startup validation","Fail fast on empty env vars/config keys","Trim and filter empty entries when splitting the host list"],"tags":["zookeeper","configuration","validation","go"],"backgroundTag":"missing-env-var","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}