Repository navigation
Conversation
A reversed window loaded every entry, kept nothing, and printed an empty report with exit 0, which reads as "no usage data" rather than a typo. Both bounds are already normalized to YYYYMMDD, so the check is a string comparison that runs after config bounds and flags are merged, for every report command.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe CLI parser now rejects reversed ChangesDate window validation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to Reversed date windows are consistently rejected across supported report commands and merged configuration inputs. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Pullfrog could not complete the automated PR review. The PR was left open for maintainer review. |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="rust/crates/ccusage-cli-parser/src/parser.rs">
<violation number="1" location="rust/crates/ccusage-cli-parser/src/parser.rs:1112">
P3: The new date-window check also fires for `ccusage statusline`, even though statusline never uses `--since`/`--until`. `report_shared` falls back to `root_shared` for `Command::Statusline`, so a config file with a reversed `defaults.since`/`defaults.until` now makes `ccusage statusline` fail to parse and exit non-zero, while `run_statusline`/`statusline_shared` in `rust/crates/ccusage/src/commands/mod.rs` never read those bounds (they build a fresh `SharedArgs` without `since`/`until`). The PR scope is "every report command", and the statusline fallback is only needed by `last_option_error`; consider skipping the date-window check for statusline so a stale reversed default window doesn't break a command that ignores it.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| /// orders them. A reversed window would otherwise load everything and print an | ||
| /// empty report that looks like missing data. | ||
| fn date_window_error(command: Option<&Command>, root_shared: &SharedArgs) -> Option<String> { | ||
| let (shared, _) = report_shared(command, root_shared); |
There was a problem hiding this comment.
P3: The new date-window check also fires for ccusage statusline, even though statusline never uses --since/--until. report_shared falls back to root_shared for Command::Statusline, so a config file with a reversed defaults.since/defaults.until now makes ccusage statusline fail to parse and exit non-zero, while run_statusline/statusline_shared in rust/crates/ccusage/src/commands/mod.rs never read those bounds (they build a fresh SharedArgs without since/until). The PR scope is "every report command", and the statusline fallback is only needed by last_option_error; consider skipping the date-window check for statusline so a stale reversed default window doesn't break a command that ignores it.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At rust/crates/ccusage-cli-parser/src/parser.rs, line 1112:
<comment>The new date-window check also fires for `ccusage statusline`, even though statusline never uses `--since`/`--until`. `report_shared` falls back to `root_shared` for `Command::Statusline`, so a config file with a reversed `defaults.since`/`defaults.until` now makes `ccusage statusline` fail to parse and exit non-zero, while `run_statusline`/`statusline_shared` in `rust/crates/ccusage/src/commands/mod.rs` never read those bounds (they build a fresh `SharedArgs` without `since`/`until`). The PR scope is "every report command", and the statusline fallback is only needed by `last_option_error`; consider skipping the date-window check for statusline so a stale reversed default window doesn't break a command that ignores it.</comment>
<file context>
@@ -1092,6 +1105,17 @@ fn last_option_error(command: Option<&Command>, root_shared: &SharedArgs) -> Opt
+/// orders them. A reversed window would otherwise load everything and print an
+/// empty report that looks like missing data.
+fn date_window_error(command: Option<&Command>, root_shared: &SharedArgs) -> Option<String> {
+ let (shared, _) = report_shared(command, root_shared);
+ let since = shared.since.as_deref()?;
+ let until = shared.until.as_deref()?;
</file context>
There was a problem hiding this comment.
ℹ️ No critical issues — one minor observation inline, otherwise mergeable.
Reviewed changes
Reviewed fb0409f end to end via the raw diff (3 files).
- Reversed window rejection — new
date_window_errorinccusage-cli-parserrejects--sincelater than--untilwith exit 2 and a usage hint, afterlast_option_errorso flag/config mixes are covered. - Shared resolver refactor — per-command shared-args match extracted into
report_sharedreused by both checks, no behavior change to--lastvalidation. - Tests and docs — exact-error cases across bare, unified,
session,claude session,blocks, andcodex monthly, plus equal-date acceptance and config/flag merge cases; one sentence added to the CLI options guide.
Muse Spark Contributor (free via Pullfrog for OSS) | 𝕏
| let since = shared.since.as_deref()?; | ||
| let until = shared.until.as_deref()?; | ||
| (since > until) | ||
| .then(|| format!("The --since date '{since}' is later than the --until date '{until}'.")) |
There was a problem hiding this comment.
Shows the normalized YYYYMMDD form even when the user typed YYYY-MM-DD. Still recognizable, so not blocking — only note it if you want the message to echo the original spelling like the invalid-date error does.
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
|
Thank you for the fix. Maintainer review found one |

Fixes #1729.
A window whose
--sincedate is later than its--untildate previously loaded every entry, kept nothing, and printed an empty report with exit 0, which reads as "no usage data" rather than a typo in the flags.Both bounds are already normalized to
YYYYMMDDbefore storage, so the newdate_window_errorcheck inccusage-cli-parseris a string comparison. It runs afterlast_option_error, once config bounds and flags are merged, so it covers flags, config-file bounds, and a mix of both, for every report command. The per-command shared-args match thatlast_option_errorused is now a sharedreport_sharedhelper so both checks read the same effective options.Error and exit code follow the existing date-bound rejection from #1604:
Tests cover bare, unified,
session,claude session,blocks, andcodex monthlyinvocations, an equal-date window, a configsincewith a flaguntil, and a real config file whose reversed window is rejected and then repaired by a flag. The CLI options guide gets one sentence.Validation:
cargo test -p ccusage-cli-parser(85 passed),cargo clippy --all-targets -D warnings,cargo fmt --check, and the release binary end to end.Summary by cubic
Fixes #1729 by rejecting a date window whose
--sincedate is later than its--untildate. Previously such a window loaded every entry, kept nothing, and printed an empty report with exit 0, which read as missing data rather than a typo.YYYYMMDD, so the validation is a simple string comparison.Written for commit fb0409f. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
--sincedate is later than the--untildate.Documentation