fix(sports): swallow a network-level headshot fetch failure instead of leaking a bare TypeError (BIT-31961) #283

Merged
spark merged 1 commits from fix/BIT-31961-sports-headshot-fetch-failed into main 2026-11-20 04:30:06 +00:00
Owner

BIT-31961 — third recurrence (ERRSIG e4af6ce83729)

saveHeadshot() in apps/api/src/sports/service.ts awaited this.deps.fetch() with no try/catch. When the headshot URL was unreachable, the bare undici TypeError: fetch failed propagated to the caller's .catch, which logged it via log.warn({err}).

Pino's logHooks fingerprints any warn carrying an Error, and a bare undici fetch failure has no stack frame in our code, so it collapsed into the same ERRSIG (e4af6ce83729) as every other unwrapped fetch site in the api component — reopening BIT-31961 a third time even though the stripe and invoicexpress call sites (PR #256) were already wrapped and deployed.

The headshot batch runs in the api process via archive.syncSquads → sports.syncEventSquads, so its component is api — matching the recurring fingerprint.

Fix

Catch the network failure inside saveHeadshot, log the reason as a plain string (no err object, so logHooks does not fingerprint a bare TypeError), and return false. A headshot that can't be downloaded is not worth paging; the next sync retries it. This is the last bare fetch call site reachable from the api component.

Tests

  • npx vitest run apps/api/src/sports/service.test.ts — 10/10 passing (new regression test asserting no bare err reaches the warn path).
  • npx tsc --noEmit -p apps/api/tsconfig.json — clean for touched files.
  • apps/api/test/{shop,invoicing,desktop-updates} failures are pre-existing (DB-dependent integration tests, fail identically on clean main).

Paperclip-Issue: BIT-31961
Paperclip-ERRSIG: e4af6ce83729

## BIT-31961 — third recurrence (ERRSIG e4af6ce83729) `saveHeadshot()` in `apps/api/src/sports/service.ts` awaited `this.deps.fetch()` with no try/catch. When the headshot URL was unreachable, the bare undici `TypeError: fetch failed` propagated to the caller's `.catch`, which logged it via `log.warn({err})`. Pino's `logHooks` fingerprints any warn carrying an Error, and a bare undici fetch failure has no stack frame in our code, so it collapsed into the **same ERRSIG** (`e4af6ce83729`) as every other unwrapped fetch site in the `api` component — reopening BIT-31961 a third time even though the stripe and invoicexpress call sites (PR #256) were already wrapped and deployed. The headshot batch runs in the api process via `archive.syncSquads → sports.syncEventSquads`, so its component is `api` — matching the recurring fingerprint. ### Fix Catch the network failure inside `saveHeadshot`, log the reason as a plain string (no `err` object, so `logHooks` does not fingerprint a bare TypeError), and return `false`. A headshot that can't be downloaded is not worth paging; the next sync retries it. This is the last bare `fetch` call site reachable from the `api` component. ### Tests - `npx vitest run apps/api/src/sports/service.test.ts` — 10/10 passing (new regression test asserting no bare `err` reaches the warn path). - `npx tsc --noEmit -p apps/api/tsconfig.json` — clean for touched files. - `apps/api/test/{shop,invoicing,desktop-updates}` failures are pre-existing (DB-dependent integration tests, fail identically on clean main). Paperclip-Issue: BIT-31961 Paperclip-ERRSIG: e4af6ce83729
spark added 1 commit 2026-11-20 04:18:46 +00:00
fix(sports): swallow a network-level headshot fetch failure instead of leaking a bare TypeError (BIT-31961)
ci / rust (pull_request) Successful in 4m18s
ci / typescript (pull_request) Successful in 10m29s
b2de0d4215
saveHeadshot() awaited this.deps.fetch() with no try/catch. When the headshot
URL was unreachable (DNS, connection reset, timeout), the bare undici
TypeError: fetch failed propagated to the caller's .catch, which logged it via
log.warn({err}). Pino's logHooks fingerprints any warn carrying an Error, and a
bare undici fetch failure has no stack frame in our code, so it collapsed into
the same ERRSIG (e4af6ce83729) as every other unwrapped fetch site in the api
component — reopening BIT-31961 a third time even though the stripe and
invoicexpress call sites (PR #256) were already wrapped and deployed.

A headshot that can't be downloaded is not worth paging: catch the network
failure inside saveHeadshot, log the reason as a plain string (no err object,
so logHooks does not fingerprint it), and return false. The next sync retries
it. This is the last bare fetch call site reachable from the api component.

Paperclip-Issue: BIT-31961
Paperclip-ERRSIG: e4af6ce83729
spark merged commit a661742733 into main 2026-11-20 04:30:06 +00:00
Sign in to join this conversation.