fix(stats): accept UUID task IDs in cf stats --task (#744)#826
Conversation
v2 task IDs are UUID strings, but 'cf stats tokens --task' and 'cf stats export --task' typed the option as Optional[int], so Typer rejected any real v2 task ID at coercion time and per-task cost/token reporting/export was broken. Widen the CLI options to Optional[str] and the repository signatures get_task_token_summary/get_batch_token_usage (+ tracker passthrough) to Union[int, str]. token_usage.task_id is already TEXT, so UUID rows round-trip unchanged. Closes #744
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 47 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ReviewClean, minimal type-widening fix — no logic changes, and it's consistent with how
No bugs found. One trivial, non-blocking nit: the Test coverage is solid for the fix's scope: CLI exit-code regression ( |
Closes #744
Problem
v2 task IDs are UUID strings, but
cf stats tokens --taskandcf stats export --tasktyped the--taskoption asOptional[int]. Typer rejected any real v2 UUID at coercion time (is not a valid integer, exit 2), so per-task cost/token reporting and export were broken for every v2 task.Fix
Type-only widening — no logic change:
stats_commands.py:tokens()/export_data()--task→Optional[str]token_repository.py:get_task_token_summary/get_batch_token_usage→Union[int, str]metrics_tracker.py:get_task_token_summarypassthrough →Union[int, str]token_usage.task_idis alreadyTEXT(schema_manager.py:172), so UUID rows round-trip unchanged; SQLite?-binding never cared about the annotation. The break was purely Typer'sintcoercion.Acceptance criteria (from #744)
--taskisstr;get_task_token_summary/get_batch_token_usageacceptUnion[int, str]cf stats tokens --task <uuid>returns a saved UUID-keyed rowTests
tests/cli/test_stats_task_uuid.py(new):cf stats tokens --task <uuid>→ exit 0, correct totals (was exit 2 pre-fix)cf stats export --task <uuid>→ writes the UUID-keyed recordget_task_token_summary(<uuid>)→ aggregated rowVerified live end-to-end:
cf stats tokens --task <uuid>andcf stats exportboth render/export the saved UUID-keyed row. All 32 tests across changed modules pass; ruff clean.Known limitations
--task 1(a validstr) — left as-is.