Skip to content

fix(spend): reject a --days window wider than a year - #140

Closed
Hayabusa-YL wants to merge 1 commit into
laaielichter:mainfrom
Hayabusa-YL:hash107
Closed

Hayabusa-YL wants to merge 1 commit into
laaielichter:mainfrom
Hayabusa-YL:hash107

Conversation

@Hayabusa-YL

Copy link
Copy Markdown

What

gulliver spend --days <huge> overflows the date arithmetic in runaway.spend: timedelta(days=...) receives a value wider than the supported range and raises before the ledger is read.

Fix

Validate --days against 1-365 (the same window gulliver top accepts for its history argument) and return a clean error instead:

--days must be between 1 and 365.

Verification

  • New test test_spend_refuses_days_above_365 covers days=1000000 and days=99999999999.
  • Full suite: 871 passed, 11 skipped.

Closes #107

timedelta(days=...) overflows before any ledger line is read when --days
is huge, so the report died with a raw traceback. Validate the window
against 1-365 (the same bound gulliver top uses) and return a clean
error instead.

Closes laaielichter#107

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Gulliver, @Hayabusa-YL, and thank you for the PR. The fix itself is the right shape: it checks the window before timedelta can overflow and returns the clean status: "error".

Why I cannot take this one forward. #107 was claimed by @rohangoud17 on the issue at 20:37 on 2026-11-10 ("I'd like to work on this one too", with a plan), about four hours before this PR was opened at 00:57 today, and I have assigned the issue to them. The project rule is that the first claim goes forward, so a second PR for the same issue only costs both of us time. This is not about the quality of your code. The comment on the issue is the part that is easy to miss: for next time, please comment on an issue first (a one-line "I'd like to take this" is enough) and you will be assigned.

For the record, if you want to keep your work: the issue's "Done when" also asks for a test through main([...]), a test one above the limit (366) and that --days 365 still works, a line under Unreleased in CHANGELOG.md (at the end of ### Fixed), and a sentence saying why 365 was chosen (the issue asks to check what window the ledger allows). Please do not push more to this PR for now.

Where to go next: please read CONTRIBUTING.md for the setup. A free good first issue that nobody has claimed is #127 (an unknown default_connection in gulliver.toml is quietly replaced by another connection). Comment on it first and you will be assigned.

If Gulliver is useful to you, a ⭐ helps other people find it.

CI: the runs for this commit are action_required (GitHub holds a first-time contributor's run until a maintainer approves it), so no check has run on this PR.


Generated by Claude Code

Copy link
Copy Markdown
Owner

@Hayabusa-YL a short follow-up to my review: #107 was claimed first by @rohangoud17, whose PR #161 is now reviewed and goes forward, so this PR will not be merged. Thank you again for the fix, it had the right shape. I will close it in favour of #161; #127 is still free if you want another issue (comment on it first and you will be assigned).


Generated by Claude Code

Copy link
Copy Markdown
Owner

Closed in favour of #161. Correction to my last comment: #127 already has an open PR (#162), so it is not free. Please pick any open issue without an assignee or PR from #57 instead, and comment on it first.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spend: a very large --days crashes with a Python traceback instead of an error message

2 participants