{"record":{"id":"8f6112b005b308d0","repo":"JuliusBrussee/caveman","slug":"unknown-stats-report-option-s","errorCode":null,"errorMessage":"unknown stats report option %s","messagePattern":"unknown stats report option (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/cmd/caveman-proxy/stats.go","lineNumber":56,"sourceCode":"\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\":\n\t\t\t\tout, writeReport = value, true\n\t\t\t}\n\t\tdefault:\n\t\t\treturn opts, false, \"\", fmt.Errorf(\"unknown stats report option %s\", arg)\n\t\t}\n\t}\n\treturn opts, writeReport, out, nil\n}\n\nfunc runStatsReport(logger *slog.Logger, args []string) {\n\topts, writeReport, out, err := parseStatsReportOptions(args)\n\tif err != nil {\n\t\tlogger.Error(\"invalid stats options\", \"error\", err)\n\t\tos.Exit(2)\n\t}\n\thome := mustHome(logger)\n\tspend := mustStore(logger, home)\n\tdefer spend.Close()\n\treport, err := spend.BuildStatsReport(opts)\n\tif err != nil {\n\t\tfatalJSON(logger, err)\n\t\treturn","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/cmd/caveman-proxy/stats.go#L38-L74","documentation":"parseStatsReportOptions (proxy/cmd/caveman-proxy/stats.go:56) recognizes a fixed set of options (--report, --json, --write-report, --days, --provider, --model, --agent, --auth, --out). Any other token that does not match a case is rejected with 'unknown stats report option <arg>'. It is a strict allowlist parser — no positional args are accepted.","triggerScenarios":"Typo'd flags like --day or --providers; passing an unexpected positional argument such as a filename; reusing flags from a different subcommand.","commonSituations":"Typos and singular/plural mistakes; muscle memory from other CLIs (--since/--from); pasting a command meant for another subcommand; trailing junk in a script variable.","solutions":["Use only the documented flags: --report, --json, --write-report, --days, --provider, --model, --agent, --auth, --out","Fix typos (e.g. --day → --days)","Remove positional arguments; all input to this command comes via flags","Check the subcommand you intended — other subcommands accept different flags"],"exampleFix":"// before\ncaveman-proxy stats --since 7d --report\n// after\ncaveman-proxy stats --days 7 --report","handlingStrategy":"validation","validationCode":"ALLOWED = {\"--report\",\"--json\",\"--write-report\",\"--days\",\"--provider\",\"--model\",\"--agent\",\"--auth\",\"--out\"}\nunknown = [a for a in args if a.startswith(\"--\") and a not in ALLOWED]\nif unknown:\n    raise ValueError(f\"unknown options: {unknown}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a canonical copy-paste template of valid stats flags","Check the subcommand's --help before reusing flags from other commands","Strip stray positional args from scripted invocations"],"tags":["cli","unknown-flag","argument-parsing","stats"],"backgroundTag":"invalid-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"}