{"record":{"id":"c72893ad38aea8fb","repo":"JuliusBrussee/caveman","slug":"s-requires-a-value","errorCode":null,"errorMessage":"%s requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/cmd/caveman-proxy/stats.go","lineNumber":34,"sourceCode":"// (telemetry and session footers) keep their original schema and behavior.\nfunc parseStatsReportOptions(args []string) (store.StatsReportOptions, bool, string, error) {\n\topts := store.StatsReportOptions{Days: 30, Now: time.Now()}\n\twriteReport, out := false, \"\"\n\tseen := map[string]bool{}\n\tfor i := 0; i < len(args); i++ {\n\t\targ := args[i]\n\t\tif seen[arg] {\n\t\t\treturn opts, false, \"\", fmt.Errorf(\"duplicate %s\", arg)\n\t\t}\n\t\tseen[arg] = true\n\t\tswitch arg {\n\t\tcase \"--report\", \"--json\":\n\t\tcase \"--write-report\":\n\t\t\twriteReport = true\n\t\tcase \"--days\", \"--provider\", \"--model\", \"--agent\", \"--auth\", \"--out\":\n\t\t\ti++\n\t\t\tif i >= len(args) || args[i] == \"\" || strings.HasPrefix(args[i], \"--\") || strings.ContainsAny(args[i], \"\\x00\\r\\n\") {\n\t\t\t\treturn opts, false, \"\", fmt.Errorf(\"%s requires a value\", arg)\n\t\t\t}\n\t\t\tvalue := args[i]\n\t\t\tswitch arg {\n\t\t\tcase \"--days\":\n\t\t\t\tdays, err := strconv.Atoi(value)\n\t\t\t\tif err != nil || days < 0 || days > 3660 {\n\t\t\t\t\treturn opts, false, \"\", fmt.Errorf(\"--days must be an integer from 0 to 3660\")\n\t\t\t\t}\n\t\t\t\topts.Days = days\n\t\t\tcase \"--provider\":\n\t\t\t\topts.Provider = value\n\t\t\tcase \"--model\":\n\t\t\t\topts.Model = value\n\t\t\tcase \"--agent\":\n\t\t\t\topts.Agent = value\n\t\t\tcase \"--auth\":\n\t\t\t\topts.AuthMode = value\n\t\t\tcase \"--out\":","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/cmd/caveman-proxy/stats.go#L16-L52","documentation":"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'.","triggerScenarios":"'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.","commonSituations":"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.","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"],"exampleFix":"// before (empty expansion)\ncaveman-proxy stats --model $MODEL --report\n// after\ncaveman-proxy stats --model \"${MODEL:-claude-fable-5}\" --report","handlingStrategy":"validation","validationCode":"opts = {\"--days\": \"7\", \"--provider\": \"anthropic\"}\nfor flag, val in opts.items():\n    if not val or val.startswith(\"--\") or \"\\n\" in val:\n        raise ValueError(f\"{flag} requires a non-empty value\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","missing-value","argument-parsing","stats"],"backgroundTag":"missing-cli-argument","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}