Skip to content

fix(stats): preserve usage error status in aggregates and doctor - #512

Merged
VickyXAI merged 2 commits into
BlockRunAI:mainfrom
Tyagiquamar:fix/stats-error-status-parsing
Oct 26, 2026
Merged

VickyXAI merged 2 commits into
BlockRunAI:mainfrom
Tyagiquamar:fix/stats-error-status-parsing

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Usage statistics now include an accurate count of requests marked as errors, alongside the total request count.
    • Diagnostic reports now reflect the number of errors recorded in usage logs instead of always reporting zero.
    • Recent logs display entries marked as errors as “ERROR” and successful entries as “OK,” making their outcomes easier to distinguish.

JSONL usage logs record per-request status but parseLogFile dropped it, so /stats and doctor always reported successes. Preserve status, count errors in getStats, and surface the count in doctor diagnostics.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d7eebfa and f45f0e3.

Files selected for processing: 1
  • src/stats.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

Statistics now count error entries in usage logs. Doctor log information reports the count returned by the statistics function.

Changes: Error count reporting

Layer / File(s) Summary
Count errors in log statistics
src/stats.ts, src/stats.error-status.test.ts
Statistics preserve recognized error and success statuses and include an error count. The test checks request and error counts, and verifies that recent logs include ERROR.
Report errors in doctor log information
src/doctor.ts
collectLogInfo reports the error count returned by getStats(1) instead of a constant zero.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: vickyxai

Merge Risk: Minimal · up to f45f0

The error-count reporting change is consistent across statistics and doctor, with no merge-blocking risk identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving usage error status in aggregates and doctor reporting.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@VickyXAI VickyXAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Tyagiquamar, good catch. parseLogFile was dropping status, so failed requests never showed as ERROR in clawrouter logs and doctor always reported 0 errors. Your test fails on main and passes here. I pushed a small follow-up (f45f0e3): prettier formatting on src/stats.ts (CI's format check would have failed), and removed the now-redundant status cast in formatRecentLogs.

@VickyXAI
VickyXAI merged commit d7ac185 into BlockRunAI:main Oct 26, 2026
5 checks passed
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.

2 participants