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'.

Solutions

  1. Set the connect string to at least one host:port, e.g. "zk1:2181,zk2:2181" (optionally with chroot: "zk1:2181/app/ns").
  2. Check the config source (env var, config file, secret) is actually populated at runtime — log or print the resolved value.
  3. Fix templating/escaping issues that dropped the server list.
  4. 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

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


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/cf5d7c8b4f235307. Report an issue: GitHub.

Appendix: 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)