fix(orb): degrade getOrbGlobalStats to zeros on a DB error - #8912
fix(orb): degrade getOrbGlobalStats to zeros on a DB error#8912jeffrey701 wants to merge 1 commit into
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8912 +/- ##
==========================================
- Coverage 93.84% 90.55% -3.29%
==========================================
Files 803 97 -706
Lines 80084 22508 -57576
Branches 24277 3893 -20384
==========================================
- Hits 75157 20383 -54774
+ Misses 3562 1945 -1617
+ Partials 1365 180 -1185
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Caution 🛑 LoopOver review result - fixes requiredReview updated: 2026-07-26 13:35:05 UTC
Review summary Nits — 4 non-blocking
CI checks failing
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
LoopOver is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
What
getOrbGlobalStats(src/orb/outcomes.ts) runs inPromise.all([getOrbGlobalStats(env), computeFleetAnalytics(env)])insrc/review/public-stats.ts. Its siblingcomputeFleetAnalyticswraps its DB reads in try/catch anddegrades to an all-null/zero report on any D1 error — but
getOrbGlobalStatshad no such guard, so aD1 error on its join query (the exact "exceeded its CPU time limit and was reset" failure the function's
own header documents) threw straight out of the
Promise.all. The only net was the route-level catch,which then 503s the entire
/v1/public/statspayload (accuracyTrend, reuseRateTrend,reviewVolumeTrend, rulePrecision all lost) instead of degrading just the orb aggregate.
Change
Wrap the query in try/catch, returning
{ merged: 0, closed: 0, total: 0 }on failure — matchingcomputeFleetAnalytics's degrade-gracefully posture exactly, so a D1 error drops only the orb aggregaterather than the whole stats payload.
Validation
test/integration/orb-outcomes.test.ts: an injected DB whosefirst()rejects makesgetOrbGlobalStatsresolve to{ merged: 0, closed: 0, total: 0 }rather than throw.npx vitest run test/integration/orb-outcomes.test.ts→ 11/11 pass; the new catch branch is covered(lcov-verified), the existing success paths remain covered.
Closes #8879