JuliusBrussee/caveman · error

unknown stats report option

Error message

unknown stats report option %s

What it means

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.

Solutions

  1. Use only the documented flags: --report, --json, --write-report, --days, --provider, --model, --agent, --auth, --out
  2. Fix typos (e.g. --day → --days)
  3. Remove positional arguments; all input to this command comes via flags
  4. Check the subcommand you intended — other subcommands accept different flags

Example fix

// before
caveman-proxy stats --since 7d --report
// after
caveman-proxy stats --days 7 --report
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {"--report","--json","--write-report","--days","--provider","--model","--agent","--auth","--out"}
unknown = [a for a in args if a.startswith("--") and a not in ALLOWED]
if unknown:
    raise ValueError(f"unknown options: {unknown}")

Prevention

When it happens

Trigger: Typo'd flags like --day or --providers; passing an unexpected positional argument such as a filename; reusing flags from a different subcommand.

Common situations: 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.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/8f6112b005b308d0. Report an issue: GitHub.

Appendix: source

Thrown at proxy/cmd/caveman-proxy/stats.go:56

			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, nil
}

func runStatsReport(logger *slog.Logger, args []string) {
	opts, writeReport, out, err := parseStatsReportOptions(args)
	if err != nil {
		logger.Error("invalid stats options", "error", err)
		os.Exit(2)
	}
	home := mustHome(logger)
	spend := mustStore(logger, home)
	defer spend.Close()
	report, err := spend.BuildStatsReport(opts)
	if err != nil {
		fatalJSON(logger, err)
		return

View on GitHub (pinned to 3ee70a1026)