t8y2/dbx · error
base_sleep_time_ms must be non-negative
Error message
base_sleep_time_ms must be non-negative
What it means
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.
Source
Thrown at agents/drivers/zookeeper/connection.go:166
func openClient(config connectionConfig) (*clientSession, error) {
if hasTLSOptions(config) {
return nil, errors.New("ZooKeeper TLS is not supported")
}
authScheme := resolveAuthScheme(config)
if authScheme != defaultAuthScheme && authScheme != saslDigestAuthScheme {
return nil, fmt.Errorf("Unsupported auth_scheme %q; expected %q or %q", authScheme, defaultAuthScheme, saslDigestAuthScheme)
}
if authScheme == saslDigestAuthScheme {
if strings.TrimSpace(config.Username) == "" {
return nil, errors.New(`username is required when auth_scheme = "sasl_digest"`)
}
if config.Password == "" {
return nil, errors.New(`password is required when auth_scheme = "sasl_digest"`)
}
}
if config.BaseSleepTimeMS != nil && *config.BaseSleepTimeMS < 0 {
return nil, errors.New("base_sleep_time_ms must be non-negative")
}
if config.MaxRetries != nil && *config.MaxRetries < 0 {
return nil, errors.New("max_retries must be non-negative")
}
maxBufferSize, err := resolveMaxBufferSize(config)
if err != nil {
return nil, err
}
target, err := parseConnectTarget(connectionString(config))
if err != nil {
return nil, err
}
connectionTimeout := millisecondsOrDefault(config.ConnectionTimeoutMS, defaultConnectionTimeout)
probeTimeout := minDuration(defaultProbeTimeout, connectionTimeout)
if err := requireReachableServer(target.Servers, probeTimeout); err != nil {
return nil, err
}View on GitHub (pinned to c0390bff16)
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
Example fix
// before
base := -1 // sentinel for "auto"
cfg := connectionConfig{BaseSleepTimeMS: &base}
// after
cfg := connectionConfig{} // leave nil to use the default backoff Defensive patterns
Strategy: validation
Validate before calling
if cfg.BaseSleepTimeMS != nil && *cfg.BaseSleepTimeMS < 0 {
return errors.New("base_sleep_time_ms must be non-negative")
} Try / catch
_, err := openClient(cfg)
if err != nil && strings.Contains(err.Error(), "base_sleep_time_ms") {
return fmt.Errorf("fix retry backoff config: %w", err)
} Prevention
- 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
When it happens
Trigger: connectionConfig.BaseSleepTimeMS is a non-nil pointer to a negative integer when connect or testConnection calls openClient.
Common situations: 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'.
Understand the failure class
Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.
Related errors
- max_retries must be non-negative
- ZooKeeper server list is empty
- Unsupported auth_scheme %q; expected %q or %q
- ZooKeeper connect string contains no servers
- %s must be between 1 and %d bytes
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/208f59ad8eb13cf8.
Report an issue: GitHub.