{"record":{"id":"c5fea659cc29ae3d","repo":"t8y2/dbx","slug":"zookeeper-auth-scheme-and-credentials-must-be-conf-c5fea6","errorCode":null,"errorMessage":"ZooKeeper auth scheme and credentials must be configured together","messagePattern":"ZooKeeper auth scheme and credentials must be configured together","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/discovery.go","lineNumber":114,"sourceCode":"\taddresses := make([]string, 0, len(discovery.servers))\n\tfor _, server := range discovery.servers {\n\t\taddresses = append(addresses, server.address())\n\t}\n\ttimeout := discovery.timeout\n\tif timeout <= 0 {\n\t\ttimeout = defaultConnectTimeout\n\t}\n\tconnection, events, err := discovery.dialer(addresses, timeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"connect to ZooKeeper: %w\", err)\n\t}\n\tdefer connection.Close()\n\tif err := waitForZooKeeperSession(ctx, events, timeout); err != nil {\n\t\treturn nil, err\n\t}\n\tif discovery.authScheme != \"\" || discovery.auth != \"\" {\n\t\tif discovery.authScheme == \"\" || discovery.auth == \"\" {\n\t\t\treturn nil, errors.New(\"ZooKeeper auth scheme and credentials must be configured together\")\n\t\t}\n\t\tif err := connection.AddAuth(discovery.authScheme, []byte(discovery.auth)); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"authenticate to ZooKeeper: %w\", err)\n\t\t}\n\t}\n\tresolved := make([]endpoint, 0)\n\tvar listedPath string\n\tvar nodeFailures []string\n\tfor _, path := range discovery.paths() {\n\t\tchildren, _, childrenErr := connection.Children(path)\n\t\tif errors.Is(childrenErr, zk.ErrNoNode) {\n\t\t\tcontinue\n\t\t}\n\t\tif childrenErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"list ZooKeeper namespace %s: %w\", path, childrenErr)\n\t\t}\n\t\tlistedPath = path\n\t\tfor _, child := range children {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/discovery.go#L96-L132","documentation":"Endpoints() validates ZooKeeper SASL configuration before authenticating: if either authScheme or auth is set but not both, configuration is incomplete and the discovery refuses to proceed. This prevents sending a malformed AddAuth call to the ZooKeeper ensemble.","triggerScenarios":"Calling Endpoints on a ZooKeeper discovery constructed with only authScheme set (e.g. \"digest\") or only auth credentials set, without the matching counterpart.","commonSituations":"Configuring only zookeeper.auth.scheme in a config file assuming the library adds the default scheme, or passing credentials without the scheme after migrating from a client that inferred it.","solutions":["Set both authScheme (e.g. \"digest\") and auth (\"user:password\") together in the discovery config","Remove both fields if no ZooKeeper auth is actually required","Validate config at startup so one-sided auth values fail fast","Check documentation for the expected auth format (scheme name plus user:password payload)"],"exampleFix":"// before\ndiscovery.authScheme = \"digest\" // auth missing\n// after\ndiscovery.authScheme = \"digest\"\ndiscovery.auth = \"hive:hivepassword\"","handlingStrategy":"validation","validationCode":"func validateZKAuth(scheme, auth string) error {\n    if (scheme == \"\") != (auth == \"\") {\n        return errors.New(\"ZooKeeper auth scheme and credentials must both be set or both empty\")\n    }\n    return nil\n}\n// call before constructing the discovery\nerr := validateZKAuth(cfg.ZKAuthScheme, cfg.ZKAuth)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set authScheme and auth as a pair in config structs","Fail config validation at application startup, not at first Endpoints call","Document that auth is scheme-qualified (e.g. digest uses user:password)"],"tags":["zookeeper","config","authentication","validation"],"backgroundTag":"incomplete-auth-configuration","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"}