fix(site): degrade gracefully when archive API returns 5xx (BIT-33540) #326

Merged
spark merged 1 commits from fix/BIT-33540-arquivo-500-graceful-degradation into main 2026-12-04 11:33:02 +00:00
Member

Fix

The /arquivo/[id] route's load() fetched /v1/archive/{id} on every request and threw archive {id}: 500 when the API had a transient Postgres outage (P2037 pool exhaustion). instrumentation.ts reported every thrown error to errors.bitreport.pt, creating an error loop.

Return null from load() on 5xx instead of throwing, mirroring the BIT-33541 pattern. ArchiveFrame renders a minimal 'temporarily unavailable' shell, and all generateMetadata callers return a default title when info is null. 404/400 still call notFound() as before.

Files changed

  • apps/site/src/app/arquivo/[id]/load.ts — return null on 5xx
  • apps/site/src/app/arquivo/[id]/frame.tsx — render fallback shell when load() returns null
  • apps/site/src/app/arquivo/[id]/page.tsx — handle null in generateMetadata
  • apps/site/src/app/arquivo/[id]/p/[personId]/page.tsx — same
  • apps/site/src/app/arquivo/[id]/g/[folderId]/page.tsx — same
  • apps/site/src/app/arquivo/[id]/f/[faceId]/page.tsx — same
  • apps/site/src/app/arquivo/[id]/load.test.ts — new tests (6 cases: 200, 500, 502, 503, 404, 400)

Tests

Test Files  3 passed (3)
     Tests 10 passed (10)

Paperclip-Issue: BIT-33540

## Fix The `/arquivo/[id]` route's `load()` fetched `/v1/archive/{id}` on every request and threw `archive {id}: 500` when the API had a transient Postgres outage (P2037 pool exhaustion). `instrumentation.ts` reported every thrown error to `errors.bitreport.pt`, creating an error loop. Return `null` from `load()` on 5xx instead of throwing, mirroring the BIT-33541 pattern. `ArchiveFrame` renders a minimal 'temporarily unavailable' shell, and all `generateMetadata` callers return a default title when `info` is `null`. 404/400 still call `notFound()` as before. ## Files changed - `apps/site/src/app/arquivo/[id]/load.ts` — return `null` on 5xx - `apps/site/src/app/arquivo/[id]/frame.tsx` — render fallback shell when `load()` returns `null` - `apps/site/src/app/arquivo/[id]/page.tsx` — handle `null` in `generateMetadata` - `apps/site/src/app/arquivo/[id]/p/[personId]/page.tsx` — same - `apps/site/src/app/arquivo/[id]/g/[folderId]/page.tsx` — same - `apps/site/src/app/arquivo/[id]/f/[faceId]/page.tsx` — same - `apps/site/src/app/arquivo/[id]/load.test.ts` — new tests (6 cases: 200, 500, 502, 503, 404, 400) ## Tests ``` Test Files 3 passed (3) Tests 10 passed (10) ``` Paperclip-Issue: BIT-33540
jos-alves added 1 commit 2026-12-04 11:13:51 +00:00
fix(site): degrade gracefully when archive API returns 5xx (BIT-33540)
ci / typescript (push) Skipped
ci / rust (push) Skipped
ci / rust (pull_request) Successful in 8m36s
ci / typescript (pull_request) Successful in 14m33s
4092e194a9
The /arquivo/[id] route's load() fetched /v1/archive/{id} on every
request and threw 'archive {id}: 500' when the API had a transient
Postgres outage (P2037 pool exhaustion). instrumentation.ts reported
every thrown error to errors.bitreport.pt, creating an error loop.

Return null from load() on 5xx instead of throwing, mirroring the
BIT-33541 pattern. ArchiveFrame renders a minimal 'temporarily
unavailable' shell, and all generateMetadata callers return a default
title when info is null. 404/400 still call notFound() as before.

Paperclip-Issue: BIT-33540
paperclip-review-bot left a comment
Member

auto-approve: CI success on 4092e194a9 (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on 4092e194a9c3 (gitea_auto_approve_open_prs_once.py)
founding-engineer left a comment
Member

auto-approve: CI success on 4092e194a9 (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on 4092e194a9c3 (gitea_auto_approve_open_prs_once.py)
devops-engineer left a comment
Member

auto-approve: CI success on 4092e194a9 (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on 4092e194a9c3 (gitea_auto_approve_open_prs_once.py)
spark merged commit aebf27f155 into main 2026-12-04 11:33:02 +00:00
Sign in to join this conversation.