{"record":{"id":"208f59ad8eb13cf8","repo":"t8y2/dbx","slug":"base-sleep-time-ms-must-be-non-negative","errorCode":null,"errorMessage":"base_sleep_time_ms must be non-negative","messagePattern":"base_sleep_time_ms must be non-negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/zookeeper/connection.go","lineNumber":166,"sourceCode":"\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 {\n\t\treturn nil, err\n\t}\n\tconnectionTimeout := millisecondsOrDefault(config.ConnectionTimeoutMS, defaultConnectionTimeout)\n\tprobeTimeout := minDuration(defaultProbeTimeout, connectionTimeout)\n\tif err := requireReachableServer(target.Servers, probeTimeout); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/zookeeper/connection.go#L148-L184","documentation":"openClient validates retry tuning parameters; base_sleep_time_ms seeds the exponential backoff between ZooKeeper connection retries and must be >= 0. A negative pointer-dereferenced value is rejected with this error.","triggerScenarios":"connectionConfig.BaseSleepTimeMS is a non-nil pointer to a negative integer when connect or testConnection calls openClient.","commonSituations":"Computed backoff value accidentally negative (e.g. subtraction underflow); YAML/JSON numeric parse producing a negative; confusing ms with seconds and entering a sentinel negative for 'auto'.","solutions":["Set base_sleep_time_ms to a non-negative value (e.g. 100-1000ms is typical)","Leave base_sleep_time_ms unset (nil) to use the driver default","Audit the code computing the value for underflow/sign errors","Remember max_retries retries use roughly base * 2^attempt backoff"],"exampleFix":"// before\nbase := -1 // sentinel for \"auto\"\ncfg := connectionConfig{BaseSleepTimeMS: &base}\n// after\ncfg := connectionConfig{} // leave nil to use the default backoff","handlingStrategy":"validation","validationCode":"if cfg.BaseSleepTimeMS != nil && *cfg.BaseSleepTimeMS < 0 {\n    return errors.New(\"base_sleep_time_ms must be non-negative\")\n}","typeGuard":null,"tryCatchPattern":"_, err := openClient(cfg)\nif err != nil && strings.Contains(err.Error(), \"base_sleep_time_ms\") {\n    return fmt.Errorf(\"fix retry backoff config: %w\", err)\n}","preventionTips":["Clamp computed backoff values with max(0, v) before assigning","Leave BaseSleepTimeMS nil to use driver defaults unless tuning is deliberate","Never use negative numbers as sentinels for 'auto' in this config","Unit-test config parsing for sign and unit (ms vs s) mistakes"],"tags":["zookeeper","configuration","validation","retry"],"backgroundTag":"invalid-configuration-value","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"}