{"record":{"id":"663b646862234243","repo":"t8y2/dbx","slug":"username-is-required-when-auth-scheme-sasl-dige","errorCode":null,"errorMessage":"username is required when auth_scheme = \"sasl_digest\"","messagePattern":"username is required when auth_scheme = \"sasl_digest\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/zookeeper/connection.go","lineNumber":159,"sourceCode":"\t}\n\tresult := map[string]any{}\n\tif info := databaseInfo(service.activeConfig); info != nil {\n\t\tresult[\"databaseInfo\"] = info\n\t}\n\treturn result, nil\n}\n\nfunc openClient(config connectionConfig) (*clientSession, error) {\n\tif hasTLSOptions(config) {\n\t\treturn nil, errors.New(\"ZooKeeper TLS is not supported\")\n\t}\n\tauthScheme := resolveAuthScheme(config)\n\tif authScheme != defaultAuthScheme && authScheme != saslDigestAuthScheme {\n\t\treturn nil, fmt.Errorf(\"Unsupported auth_scheme %q; expected %q or %q\", authScheme, defaultAuthScheme, saslDigestAuthScheme)\n\t}\n\tif authScheme == saslDigestAuthScheme {\n\t\tif strings.TrimSpace(config.Username) == \"\" {\n\t\t\treturn nil, errors.New(`username is required when auth_scheme = \"sasl_digest\"`)\n\t\t}\n\t\tif config.Password == \"\" {\n\t\t\treturn nil, errors.New(`password is required when auth_scheme = \"sasl_digest\"`)\n\t\t}\n\t}\n\tif config.BaseSleepTimeMS != nil && *config.BaseSleepTimeMS < 0 {\n\t\treturn nil, errors.New(\"base_sleep_time_ms must be non-negative\")\n\t}\n\tif config.MaxRetries != nil && *config.MaxRetries < 0 {\n\t\treturn nil, errors.New(\"max_retries must be non-negative\")\n\t}\n\tmaxBufferSize, err := resolveMaxBufferSize(config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttarget, err := parseConnectTarget(connectionString(config))\n\tif err != nil {","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/zookeeper/connection.go#L141-L177","documentation":"When auth_scheme is sasl_digest, SASL DIGEST-MD5 authentication requires a username; openClient enforces this before attempting the connection. The check trims whitespace, so a whitespace-only username is also rejected.","triggerScenarios":"connectionConfig has auth_scheme = \"sasl_digest\" and Username is empty or whitespace-only when openClient runs (via connect or testConnection).","commonSituations":"Setting auth_scheme to sasl_digest but forgetting credentials; credentials supplied via a secret that failed to load into the config; username field misnamed in a config file.","solutions":["Provide a non-empty username in the connection config alongside auth_scheme=sasl_digest","Verify the credential source (env var/secret manager) actually populated Username","Switch to the default auth scheme if SASL is not required","Ensure the username matches a ZooKeeper user with the needed ACLs"],"exampleFix":"// before\ncfg := connectionConfig{AuthScheme: \"sasl_digest\", Password: pwd} // no username\n// after\ncfg := connectionConfig{AuthScheme: \"sasl_digest\", Username: \"zkuser\", Password: pwd}","handlingStrategy":"validation","validationCode":"if cfg.AuthScheme == \"sasl_digest\" && strings.TrimSpace(cfg.Username) == \"\" {\n    return errors.New(\"username is required when auth_scheme = sasl_digest\")\n}","typeGuard":null,"tryCatchPattern":"_, err := openClient(cfg)\nif err != nil && strings.Contains(err.Error(), \"username is required\") {\n    return fmt.Errorf(\"supply SASL credentials: %w\", err)\n}","preventionTips":["When enabling sasl_digest, set username and password together in one change","Load credentials from a secret manager and assert non-empty before connect","Fail fast at startup if SASL env vars are missing","Keep the SASL username aligned with ZooKeeper ACL grants"],"tags":["zookeeper","authentication","sasl","configuration"],"backgroundTag":"missing-credentials","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}