t8y2/dbx · error
expected duration or positive milliseconds
Error message
expected duration or positive milliseconds
What it means
parseDurationOption accepts either a Go duration string (e.g. "5s", "100ms") or a bare positive integer treated as milliseconds. This error is returned when the value is neither a valid duration nor an integer >= 1.
Source
Thrown at agents/drivers/cassandra-go/config.go:494
}
return len(hosts) > 0
}
func hostNameOnly(host string) string {
host = strings.TrimSpace(host)
if parsedHost, _, err := net.SplitHostPort(host); err == nil {
return parsedHost
}
return strings.Trim(host, "[]")
}
func parseDurationOption(value string) (time.Duration, error) {
if duration, err := time.ParseDuration(value); err == nil {
return duration, nil
}
milliseconds, err := strconv.Atoi(value)
if err != nil || milliseconds < 1 {
return 0, fmt.Errorf("expected duration or positive milliseconds")
}
return time.Duration(milliseconds) * time.Millisecond, nil
}
func normalizeRetryPolicy(value string) (string, error) {
name := strings.ToLower(simpleClassName(value))
switch name {
case "", "defaultretrypolicy", "simpleretrypolicy":
return "simple", nil
case "fallthroughretrypolicy":
return "fallthrough", nil
case "downgradingconsistencyretrypolicy":
return "downgrading", nil
case "exponentialbackoffretrypolicy":
return "exponential", nil
default:
return "", fmt.Errorf("unsupported Cassandra retry policy: %s", value)
}View on GitHub (pinned to c0390bff16)
Solutions
- Pass a valid Go duration string such as "5s", "250ms", or "1m"
- Or pass a bare positive integer of milliseconds, e.g. "5000" for 5 seconds
- Ensure the value is at least 1 (values < 1 are rejected)
Example fix
// before cassandraURL = "cassandra://host:9042/keyspace?timeout=0" // after cassandraURL = "cassandra://host:9042/keyspace?timeout=5s"
Defensive patterns
Strategy: validation
Validate before calling
func validDurationOption(v string) bool {
if _, err := time.ParseDuration(v); err == nil {
return true
}
ms, err := strconv.Atoi(v)
return err == nil && ms >= 1
} Try / catch
d, err := parseDurationOption(raw)
if err != nil {
return fmt.Errorf("option %s=%q must be like \"5s\" or \"5000\" (ms): %w", name, raw, err)
} Prevention
- Use explicit unit suffixes ("5s", "250ms") in query params
- Never pass 0 or negative numbers for duration options
- Document valid formats next to each duration option
When it happens
Trigger: Passing a value like "abc", "0", "-500", "" or "1.5" as a duration option (e.g. request timeout) via applyCassandraURLParams.
Common situations: Putting "0" or a negative number in a Cassandra URL query parameter, or using a locale-formatted value like "5 s" with a space.
Understand the failure class
Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.
Related errors
- invalid Cassandra reconnection policy delay: %s
- parse Cassandra configfile %s: %w
- invalid useKeyTab in Cassandra JAAS config: %w
- invalid useTicketCache in Cassandra JAAS config: %w
- published HiveServer2 configuration has no valid host and po
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/3a9aaf8408d81ff9.
Report an issue: GitHub.