{"record":{"id":"3a9aaf8408d81ff9","repo":"t8y2/dbx","slug":"expected-duration-or-positive-milliseconds","errorCode":null,"errorMessage":"expected duration or positive milliseconds","messagePattern":"expected duration or positive milliseconds","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/cassandra-go/config.go","lineNumber":494,"sourceCode":"\t}\n\treturn len(hosts) > 0\n}\n\nfunc hostNameOnly(host string) string {\n\thost = strings.TrimSpace(host)\n\tif parsedHost, _, err := net.SplitHostPort(host); err == nil {\n\t\treturn parsedHost\n\t}\n\treturn strings.Trim(host, \"[]\")\n}\n\nfunc parseDurationOption(value string) (time.Duration, error) {\n\tif duration, err := time.ParseDuration(value); err == nil {\n\t\treturn duration, nil\n\t}\n\tmilliseconds, err := strconv.Atoi(value)\n\tif err != nil || milliseconds < 1 {\n\t\treturn 0, fmt.Errorf(\"expected duration or positive milliseconds\")\n\t}\n\treturn time.Duration(milliseconds) * time.Millisecond, nil\n}\n\nfunc normalizeRetryPolicy(value string) (string, error) {\n\tname := strings.ToLower(simpleClassName(value))\n\tswitch name {\n\tcase \"\", \"defaultretrypolicy\", \"simpleretrypolicy\":\n\t\treturn \"simple\", nil\n\tcase \"fallthroughretrypolicy\":\n\t\treturn \"fallthrough\", nil\n\tcase \"downgradingconsistencyretrypolicy\":\n\t\treturn \"downgrading\", nil\n\tcase \"exponentialbackoffretrypolicy\":\n\t\treturn \"exponential\", nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported Cassandra retry policy: %s\", value)\n\t}","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/cassandra-go/config.go#L476-L512","documentation":"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.","triggerScenarios":"Passing a value like \"abc\", \"0\", \"-500\", \"\" or \"1.5\" as a duration option (e.g. request timeout) via applyCassandraURLParams.","commonSituations":"Putting \"0\" or a negative number in a Cassandra URL query parameter, or using a locale-formatted value like \"5 s\" with a space.","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)"],"exampleFix":"// before\ncassandraURL = \"cassandra://host:9042/keyspace?timeout=0\"\n// after\ncassandraURL = \"cassandra://host:9042/keyspace?timeout=5s\"","handlingStrategy":"validation","validationCode":"func validDurationOption(v string) bool {\n\tif _, err := time.ParseDuration(v); err == nil {\n\t\treturn true\n\t}\n\tms, err := strconv.Atoi(v)\n\treturn err == nil && ms >= 1\n}","typeGuard":null,"tryCatchPattern":"d, err := parseDurationOption(raw)\nif err != nil {\n\treturn fmt.Errorf(\"option %s=%q must be like \\\"5s\\\" or \\\"5000\\\" (ms): %w\", name, raw, err)\n}","preventionTips":["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"],"tags":["cassandra","config","duration","parsing"],"backgroundTag":"invalid-duration-format","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"}