Skip to content

fix(cli): raise UsageError for --until + --group-by before session loading#340

Merged
decko merged 2 commits into
mainfrom
soda/318
May 26, 2026
Merged

fix(cli): raise UsageError for --until + --group-by before session loading#340
decko merged 2 commits into
mainfrom
soda/318

Conversation

@decko
Copy link
Copy Markdown
Owner

@decko decko commented May 26, 2026

Summary

--until was silently ignored when combined with --group-by in raki cohort. The mutual-exclusivity validation only ran after session loading, so:

  • With an empty sessions directory: produced exit code 1 ("no sessions found") instead of exit code 2 (usage error)
  • The flag conflict was effectively invisible to users with no sessions

Fix

Moved the --until + --group-by mutual exclusivity check to the early validation block (before session loading), consistent with the existing --since + --group-by check that was already there. Removed the now-redundant late check.

Files Changed

File Description
src/raki/cli.py Added early until_given/group_by_given check; updated comment and --group-by help text
tests/test_cohort.py Added test_until_and_group_by_are_mutually_exclusive regression test
changes/318.fix Towncrier changelog fragment

Acceptance Criteria

  • UsageError (exit 2) raised for --until + --group-by, even with empty sessions directory
  • --until + --since still works correctly (unaffected code path)
  • Regression test: test_until_and_group_by_are_mutually_exclusive
  • Towncrier fragment: changes/318.fix

Review Results

Finding 1 — MINOR (python-specialist, rag-specialist)

File: src/raki/cli.py:1791
Issue: Comment said "--since and --group-by cannot be used together" but the block also covers --until/--group-by. Comment was stale.
Resolution: ✅ Updated comment to # --- Mutual exclusivity: --since/--until and --group-by cannot be used together ---

Finding 2 & 3 — MINOR (python-specialist, rag-specialist)

File: src/raki/cli.py:1730
Issue: --group-by option help text said "Mutually exclusive with --since." but didn't mention --until.
Resolution: ✅ Updated help text to "Mutually exclusive with --since/--until."


Refs #318

Assisted-by: Claude Opus 4.6 (1M context) noreply@anthropic.com
Assigned-by: decko

decko added 2 commits May 26, 2026 10:31
…sion loading (#318)

The --until flag was silently ignored when combined with --group-by in
raki cohort because the validation happened after session loading. An
empty sessions directory produced exit 1 (no sessions found) instead of
exit 2 (usage error), making the error invisible.

- Add early mutual exclusivity check for --until + --group-by (using
  ParameterSource detection, consistent with --since/--group-by check)
- Remove the now-redundant late check in the --group-by branch
- Add regression test: test_until_and_group_by_are_mutually_exclusive
  (uses empty sessions dir to prove the check fires before loading)
- Add towncrier changelog fragment: changes/318.fix
@decko decko added the ai-assisted Implemented with AI assistance label May 26, 2026
@decko decko merged commit 5c1bfd6 into main May 26, 2026
4 checks passed
@decko decko deleted the soda/318 branch May 26, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Implemented with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant