You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
spend: a very large --days crashes with a Python traceback instead of an error message #107
gulliver spend refuses --days below 1 (#92), but a very large number crashes with a raw Python traceback instead of a message:
gulliver spend --by table --days 99999999999 --json
# OverflowError: Python int too large to convert to C int
gulliver spend --days 1000000 --json
# OverflowError: date value out of range
gulliver top --days 99999999999 already handles this well: it returns status: "error" with the message "days must be between 1 and 365." (exit code 1). spend should give the same kind of answer. Please pick the upper limit with care: top allows up to 365 days, and the receipts and ledger that spend reads may allow a different window, so check what is sensible and say so in the message.
Where to start
src/gulliver/runaway.py (around line 311): spend(...), which already refuses days < 1 and shows the _error(message, next_step) style
src/gulliver/features.py or src/gulliver/core.py: look for where top produces "days must be between 1 and 365" and reuse the idea (or the constant)
src/gulliver/cli.py: the spend parser (around line 340) and its handler
Tests: tests/test_runaway.py (spend), tests/test_cli_and_mcp.py for main([...])
Done when
spend --days N above the chosen upper limit returns status: "error" with a clear message and next_step (exit code 1), not a traceback; the limit is stated in the message
--days 1 and every valid value up to the limit behave exactly as before
A test for a huge value (for example 99999999999) and one just above the limit, through the function and through main([...])
Leave CHANGELOG.md alone; the maintainer adds the entry with credit to you when it is merged
AI-assisted. I would reuse the same practical upper bound as top: 365 days. It avoids timedelta overflow and matches the existing user-facing window.
Suggested patch in src/gulliver/runaway.py:
MAX_SPEND_DAYS=365defspend(settings: Settings, by: str="agent", days: int=7) ->dict[str, Any]:
ifbynotinSPEND_BY:
return_error(f"by must be one of {', '.join(SPEND_BY)}", "Use --by agent, day or table.")
ifdays<1:
return_error("--days must be at least 1.", "Give a positive number of days, for example --days 7.")
ifdays>MAX_SPEND_DAYS:
return_error(
f"--days must be between 1 and {MAX_SPEND_DAYS}.",
f"Use a smaller window, for example --days {MAX_SPEND_DAYS}.",
)
days=int(days)
first=now_utc().date() -timedelta(days=days-1)
The check should happen before timedelta(days=days - 1) so huge values cannot reach the date arithmetic.
Suggested tests:
spend(settings, days=99999999999) returns status: "error" with the limit in the message and a next_step;
Hi, I’d like to work on this one too. My plan: in spend (runaway.py), add an upper bound check next to the existing days < 1 check and return _error(...) with the limit stated in the message and a next_step, matching top’s “days must be between 1 and 365” behaviour. I’ll check what window the receipts/ledger support before picking the limit (reusing top’s constant if 365 makes sense) and confirm it here. Tests through spend() and main([...]) for a huge value and limit + 1, plus a changelog line. I’ll keep it as a separate PR from #138.
Thanks @rohangoud17, you asked for #107 at 20:37 on 2026-11-10, and that is the first claim on this thread (the earlier comment from @mPiha says "not claiming"), so I have assigned it to you. Your plan matches the issue.
Two things for when you start:
Another new contributor opened PR fix(spend): reject a --days window wider than a year #140 for this issue at 00:57 today without commenting on it first. I have let them know, kindly, that the claim is yours, so you can go ahead without racing anyone.
On the limit: top allows 1 to 365 days (days must be between 1 and 365, in src/gulliver/workload.py, and le=365 on the MCP tool gulliver_top). I did not find a retention limit for the ledger that spend reads, so 365 would be a choice for consistency with top, not a technical limit. The issue asks you to say what you chose and why, in the message or the PR description; one sentence is enough. Please also keep --days 1 and every value up to the limit working as before.
Please finish the small CHANGELOG fix on #138 first if you can; both PRs are small, so either order is fine.
Activity
mPiha commentedon Nov 10, 2026
AI-assisted. I would reuse the same practical upper bound as
top: 365 days. It avoidstimedeltaoverflow and matches the existing user-facing window.Suggested patch in
src/gulliver/runaway.py:The check should happen before
timedelta(days=days - 1)so huge values cannot reach the date arithmetic.Suggested tests:
spend(settings, days=99999999999)returnsstatus: "error"with the limit in the message and anext_step;spend(settings, days=366)returnsstatus: "error";spend(settings, days=1)andspend(settings, days=365)still returnstatus: "ok";main(["spend", "--days", "99999999999", "--json"])exits with code 1 and emits the same error shape;main(["spend", "--days", "366", "--json"])exits with code 1.Not claiming the issue.
rohangoud17 commentedon Nov 10, 2026
Hi, I’d like to work on this one too. My plan: in spend (runaway.py), add an upper bound check next to the existing days < 1 check and return _error(...) with the limit stated in the message and a next_step, matching top’s “days must be between 1 and 365” behaviour. I’ll check what window the receipts/ledger support before picking the limit (reusing top’s constant if 365 makes sense) and confirm it here. Tests through spend() and main([...]) for a huge value and limit + 1, plus a changelog line. I’ll keep it as a separate PR from #138.
fix(spend): reject a --days window wider than a year
laaielichter commentedon Nov 11, 2026
Thanks @rohangoud17, you asked for #107 at 20:37 on 2026-11-10, and that is the first claim on this thread (the earlier comment from @mPiha says "not claiming"), so I have assigned it to you. Your plan matches the issue.
Two things for when you start:
topallows 1 to 365 days (days must be between 1 and 365, insrc/gulliver/workload.py, andle=365on the MCP toolgulliver_top). I did not find a retention limit for the ledger thatspendreads, so 365 would be a choice for consistency withtop, not a technical limit. The issue asks you to say what you chose and why, in the message or the PR description; one sentence is enough. Please also keep--days 1and every value up to the limit working as before.Please finish the small CHANGELOG fix on #138 first if you can; both PRs are small, so either order is fine.
Generated by Claude Code
docs:credit in changelog entry for laaielichter#107
fix(spend): cap --days where the date math overflows, not at 365 (laa…
test(spend): cover long valid windows and the real --days limit (laai…