multica-ai/multica · warning
--days must be between 1 and 365
Error message
--days must be between 1 and 365
What it means
Argument validation in runRuntimeUsage: the --days flag must be an integer in [1, 365]; anything outside — including 0, negatives, >365, or a non-integer that cobra fails to parse — is rejected before any network call. This bounds the usage-history window the server must aggregate.
Source
Thrown at server/cmd/multica/cmd_runtime.go:150
strVal(rt, "runtime_mode"),
strVal(rt, "provider"),
strVal(rt, "status"),
strVal(rt, "last_seen_at"),
})
}
cli.PrintTable(os.Stdout, headers, rows)
return nil
}
func runRuntimeUsage(cmd *cobra.Command, args []string) error {
client, err := newAPIClient(cmd)
if err != nil {
return err
}
days, _ := cmd.Flags().GetInt("days")
if days < 1 || days > 365 {
return fmt.Errorf("--days must be between 1 and 365")
}
ctx, cancel := cli.APIContext(context.Background())
defer cancel()
var usage []map[string]any
path := fmt.Sprintf("/api/runtimes/%s/usage?days=%d", args[0], days)
if err := client.GetJSON(ctx, path, &usage); err != nil {
return fmt.Errorf("get runtime usage: %w", err)
}
output, _ := cmd.Flags().GetString("output")
if output == "json" {
return cli.PrintJSON(os.Stdout, usage)
}
headers := []string{"DATE", "PROVIDER", "MODEL", "INPUT_TOKENS", "OUTPUT_TOKENS", "CACHE_READ", "CACHE_WRITE"}
rows := make([][]string, 0, len(usage))View on GitHub (pinned to 2c0912b6ec)
Solutions
- Pass an integer between 1 and 365, e.g. --days 30.
- Clamp scripted input: days=$(( days<1 ? 1 : (days>365 ? 365 : days) )).
- For longer horizons, query the API directly or aggregate two windows (e.g. days 1-365 twice with date offsets) — the CLI cap mirrors the server's.
Example fix
# before multica runtime usage rt_123 --days 0 # after multica runtime usage rt_123 --days 30
Defensive patterns
Strategy: validation
Validate before calling
days, err := cmd.Flags().GetInt("days")
if err != nil || days < 1 || days > 365 {
return fmt.Errorf("--days must be an integer between 1 and 365, got %d", days)
} Prevention
- Clamp scripted inputs before passing them.
- Treat unset shell variables (0) as 30 with ${DAYS:-30}.
- Remember the cap mirrors the server; do not try to bypass via the API.
When it happens
Trigger: Running `multica runtime usage <id> --days 0`, `--days 400`, `--days -7`, or `--days 30days` (parse error surfaces via the flag binding, then range check catches valid ints out of range).
Common situations: Scripts parameterizing days from an unset variable (defaults to 0); users asking for a year+ of history (--days 366); copy-paste of ISO durations like 30d.
Related errors
- --description can only be used when adding one repository UR
- --kind must be schedule or webhook
- --cron is required for --kind schedule
- --timezone is only valid with --kind schedule
- --cron is only valid with --kind schedule
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/e5210ee676bc3090.
Report an issue: GitHub.