JuliusBrussee/caveman · error
requires a value
Error message
%s requires a value
What it means
Value-taking stats options (--days, --provider, --model, --agent, --auth, --out) must be followed by exactly one non-empty value that is not another flag (proxy/cmd/caveman-proxy/stats.go:34). When the next token is missing, empty, starts with '--', or contains NUL/CR/LF characters, the parser rejects it with '<flag> requires a value'.
Solutions
- Supply a non-empty value immediately after the flag
- Quote values containing spaces or special characters
- Check that any $VAR used as a value is actually set and non-empty
- Reorder arguments so a value never sits where another flag is expected
Example fix
// before (empty expansion)
caveman-proxy stats --model $MODEL --report
// after
caveman-proxy stats --model "${MODEL:-claude-fable-5}" --report Defensive patterns
Strategy: validation
Validate before calling
opts = {"--days": "7", "--provider": "anthropic"}
for flag, val in opts.items():
if not val or val.startswith("--") or "\n" in val:
raise ValueError(f"{flag} requires a non-empty value") Prevention
- Quote flag values with "${VAR:-default}" so unset variables never yield empty tokens
- Never place a flag where a value is expected
- Check for accidental newlines in values coming from files or command substitution
When it happens
Trigger: 'stats --provider' at end of args; 'stats --model --days 7' (flag where a value should be); '--out ""'; a value containing a newline from a badly quoted shell variable.
Common situations: Forgetting the value after a flag; empty environment variable expansion ($MODEL unset leaves an empty token); quoting mistakes dropping the value; another flag accidentally placed in the value position.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- duplicate
- unknown stats report option
- requires a value
- --days must be an integer from 0 to 3660
- duplicate
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/c72893ad38aea8fb.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/cmd/caveman-proxy/stats.go:34
// (telemetry and session footers) keep their original schema and behavior.
func parseStatsReportOptions(args []string) (store.StatsReportOptions, bool, string, error) {
opts := store.StatsReportOptions{Days: 30, Now: time.Now()}
writeReport, out := false, ""
seen := map[string]bool{}
for i := 0; i < len(args); i++ {
arg := args[i]
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":View on GitHub (pinned to 3ee70a1026)