JuliusBrussee/caveman · error
--days must be an integer from 0 to 3660
Error message
--days must be an integer from 0 to 3660
What it means
The --days option of the stats report command must parse as an integer between 0 and 3660 inclusive (proxy/cmd/caveman-proxy/stats.go:41). Any non-integer value or an out-of-range number is rejected with this fixed message, guarding StatsReportOptions.Days before it reaches the SQL time-window query.
Solutions
- Pass a plain integer between 0 and 3660, e.g. --days 30
- Convert '30d' style durations to bare numbers (--days 30)
- Use 0 deliberately to mean an unbounded/today-only window per the tool's semantics, not a negative value
Example fix
// before caveman-proxy stats --days 30d --report // after caveman-proxy stats --days 30 --report
Defensive patterns
Strategy: validation
Validate before calling
d, err := strconv.Atoi(raw)
if err != nil || d < 0 || d > 3660 {
return fmt.Errorf("--days must be an integer from 0 to 3660")
} Prevention
- Always pass plain integers, never '30d' style durations
- Clamp computed windows to 0..3660 before passing them
- Document the max window (10 years) where the command is generated
When it happens
Trigger: 'stats --days week' (non-numeric); 'stats --days -1' or 'stats --days 9999' (out of the 0–3660 range).
Common situations: Passing a duration word or '30d' instead of a plain integer; a calculator slip producing a huge window; confusion with other CLIs that accept '30d' style durations.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- stats days must be between 0 and 3660
- at least one report path and the canonical span fixture…
- at least one sink id is required
- base and head must be full Git object IDs
- cave_live_eval_sandbox_profile_invalid
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/aa1744d2b015c493.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/cmd/caveman-proxy/stats.go:41
if seen[arg] {
return opts, false, "", fmt.Errorf("duplicate %s", arg)
}
seen[arg] = true
switch arg {
case "--report", "--json":
case "--write-report":
writeReport = true
case "--days", "--provider", "--model", "--agent", "--auth", "--out":
i++
if i >= len(args) || args[i] == "" || strings.HasPrefix(args[i], "--") || strings.ContainsAny(args[i], "\x00\r\n") {
return opts, false, "", fmt.Errorf("%s requires a value", arg)
}
value := args[i]
switch arg {
case "--days":
days, err := strconv.Atoi(value)
if err != nil || days < 0 || days > 3660 {
return opts, false, "", fmt.Errorf("--days must be an integer from 0 to 3660")
}
opts.Days = days
case "--provider":
opts.Provider = value
case "--model":
opts.Model = value
case "--agent":
opts.Agent = value
case "--auth":
opts.AuthMode = value
case "--out":
out, writeReport = value, true
}
default:
return opts, false, "", fmt.Errorf("unknown stats report option %s", arg)
}
}
return opts, writeReport, out, nilView on GitHub (pinned to 3ee70a1026)