t8y2/dbx · error
ZooKeeper connect string contains no servers
Error message
ZooKeeper connect string contains no servers
What it means
parseConnectTarget splits the ZooKeeper connect string on commas into host:port server entries (with an optional chroot path). If, after trimming, no server entries remain, it returns 'ZooKeeper connect string contains no servers'.
Source
Thrown at agents/drivers/zookeeper/connection.go:376
func parseConnectTarget(value string) (connectTarget, error) {
connectString := strings.TrimSpace(strings.TrimPrefix(value, "zookeeper://"))
slash := strings.Index(connectString, "/")
hostsPart := connectString
chroot := ""
if slash >= 0 {
hostsPart = connectString[:slash]
chroot = normalizePrefix(connectString[slash:])
}
servers := make([]string, 0)
for _, item := range strings.Split(hostsPart, ",") {
server := strings.TrimSpace(item)
if server != "" {
servers = append(servers, server)
}
}
if len(servers) == 0 {
return connectTarget{}, errors.New("ZooKeeper connect string contains no servers")
}
return connectTarget{Servers: servers, Chroot: chroot}, nil
}
func requireReachableServer(servers []string, timeout time.Duration) error {
ctx, cancel := context.WithTimeout(context.Background(), timeout+500*time.Millisecond)
defer cancel()
workers := minInt(len(servers), maximumReachabilityWorkers)
jobs := make(chan string)
reachable := make(chan struct{}, 1)
var waitGroup sync.WaitGroup
for worker := 0; worker < workers; worker++ {
waitGroup.Add(1)
go func() {
defer waitGroup.Done()
for server := range jobs {
address, err := endpointAddress(server)
if err != nil {View on GitHub (pinned to c0390bff16)
Solutions
- Set the connect string to at least one host:port, e.g. "zk1:2181,zk2:2181" (optionally with chroot: "zk1:2181/app/ns").
- Check the config source (env var, config file, secret) is actually populated at runtime — log or print the resolved value.
- Fix templating/escaping issues that dropped the server list.
- Validate the config early with TestConnectionConfiguration before opening the client.
Example fix
// before config.ConnectString = "" // after config.ConnectString = "zk1:2181,zk2:2181"
Defensive patterns
Strategy: validation
Validate before calling
func validateConnectString(s string) error {
if strings.TrimSpace(s) == "" { return errors.New("zookeeper connect string is empty") }
for _, item := range strings.Split(s, ",") {
item = strings.TrimSpace(item)
if item != "" && strings.Contains(item, ":") { return nil }
}
return errors.New("zookeeper connect string has no host:port servers")
}
// call before openClient / TestConnectionConfiguration Try / catch
if err := validateConnectString(cfg.ConnectString); err != nil {
return fmt.Errorf("bad zookeeper config: %w", err)
}
session, err := openClient(cfg)
if err != nil { return err } Prevention
- Fail fast at config load time if the connect string is empty
- Log the resolved connect string (redacted) during startup
- Avoid templated config that can expand to whitespace
- Include a chroot only after valid host:port entries
When it happens
Trigger: Calling openClient, TestConnectionConfiguration, or databaseInfo with a connect string that is empty, whitespace-only, consists only of separators, or is just a chroot path with no host:port entries before it. Raised in agents/drivers/zookeeper/connection.go:376.
Common situations: Config env var or YAML key missing/empty so the connect string is ""; a typo leaving only "/chroot" in the field; template/secret expansion yielding whitespace; trailing commas producing zero non-empty items.
Related errors
- ZooKeeper server list is empty
- Unsupported auth_scheme %q; expected %q or %q
- base_sleep_time_ms must be non-negative
- max_retries must be non-negative
- %s must be between 1 and %d bytes
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/cf5d7c8b4f235307.
Report an issue: GitHub.