fix(api): return a graceful 503 badge instead of an unhandled 500 when the loader throws#8403
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
…n the loader throws (JSONbored#8377)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8403 +/- ##
==========================================
- Coverage 92.17% 90.16% -2.01%
==========================================
Files 791 98 -693
Lines 79249 25281 -53968
Branches 23945 4712 -19233
==========================================
- Hits 73048 22795 -50253
+ Misses 5062 2214 -2848
+ Partials 1139 272 -867
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-24 12:11:15 UTC
Review summary Nits — 4 non-blocking
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.
|
Summary
GET /v1/public/repos/:owner/:repo/badge.svgandbadge.jsonwere the only public GET routes with no error handling:loadPublicRepoBadgeis not fail-safe (two D1 reads plus, per its own doc, an occasional cold-cache GitHub fetch while resolving the manifest), so any transient failure escaped as Hono's bare, unstructured 500 — with noapp.onErrorregistered anywhere. Unusually visible here: these badges are unauthenticated, embedded in third-party READMEs, and served through GitHub's camo proxy, so a blip showed a broken image instead of the graceful "unavailable" badge these routes already render.try/catchthe sibling/qualityroute (and the fix(orb): drainOrbRelay returns HTTP 500 repeatedly (872 Sentry events, escalating) #4995 relay fix) already use.loadPublicRepoBadgeand everything it calls are untouched, per the issue's Requirements.renderUnavailableBadgeSvg()/ the{ schemaVersion: 1, label, message: "unavailable", color, cacheSeconds }shape — with 503, not 404, so a monitoring consumer can still tell "this repo has no public badge" (404, unchanged) apart from "the backend is having a transient problem", exactly the split/qualityalready makes.public, max-age=300cache (mirroring the existing 404 branch) so a transient failure is never cached for the longmax-age=600, stale-while-revalidate=86400window. Success/404 cache semantics are unchanged.Closes #8377
Test plan
test/integration/api.test.ts's existing badge test: with a forced D1 read failure,.svgreturns 503 withimage/svg+xml,Cache-Control: public, max-age=300, and the "unavailable" body;.jsonreturns 503 with the same short cache and the full unavailable shields payload; and the healthy path still returns 200 with the long stale-while-revalidate cachepreparewrapper (withRepositoryReadFailure, mirroring the existingwithProductUsageInsertFailure) — so the route's owncatchis what produces the responsetest/integration/api.test.tsfully green (50/50);npm run typecheckclean