test(radio): Lock YouTube provider outage failover for RADIO-25

Merged
FC
15d ago
+284-1

Summary

Investigation of RADIO-25 (YouTubeProviderAggregateError / YOUTUBE_CLIENT_RESOLUTION_FAILED, production radio@0.7.2, Chrome desktop, mode=dj, 2026-10-29).

Verified cause: every curated browser YouTube relay failed (HTTP 500 and network/CORS / Failed to fetch). Failover walked the pool, aggregated retryable provider errors, surfaced Every configured YouTube provider failed to the DJ pick UI, and reported the failure to Sentry as unexpected playback telemetry. That matches the intentional contract for volunteer Piped/Invidious outages; no app defect was shown that would justify a production change or Fixes RADIO-25.

What changed

Regression coverage only (synthetic mocked fetch/provider responses; no raw event URLs, PII, or secrets):

  • packages/platforms/src/youtube/provider.test.ts — HTTP 500 + network/CORS failover, aggregate diagnostics, recovery when a later provider succeeds
  • apps/radio/src/lib/youtube/client.test.ts — curated resolveItem pool exhaustion matching the event shape
  • apps/radio/src/lib/platform-item-loader.test.ts — loader keeps YOUTUBE_CLIENT_RESOLUTION_FAILED + aggregate cause for UI/reporting
  • packages/error/src/index.test.ts — pool exhaustion stays error_expected=false (ops visibility; not silenced)
  • apps/radio/src/lib/platform-stream-refresh.test.ts — YouTube refresh throws go through onFailed with DJ_YOUTUBE_REFRESH_FAILED request metadata

Evidence (red/green)

No failing production-path assertion was found before adding these locks; the new regressions are green against current main and document the intended behavior rather than driving a manufactured silence of unexpected errors.

Commands:

bun test packages/platforms/src/youtube/provider.test.ts \
  apps/radio/src/lib/youtube/client.test.ts \
  apps/radio/src/lib/platform-item-loader.test.ts \
  apps/radio/src/lib/platform-stream-refresh.test.ts \
  packages/error/src/index.test.ts
# 96 pass, 0 fail

bun run check   # pass
bun run typecheck  # pass

Base SHA: 7f7ed3bf52672df71a5514591af0b3a866708d0b (origin/main)

Limits / caveats

  • External relay health is outside this change; providers were not replaced or live-probed.
  • Marking pool exhaustion expected: true was rejected: existing reporting policy and tests treat YOUTUBE_CLIENT_RESOLUTION_FAILED as unexpected so curated-pool outages remain visible in Sentry.
  • DJ YouTube refresh still throws (by design) into onFailed; deck reporting currently defaults that path to PLAY_ERROR rather than the request’s DJ_YOUTUBE_REFRESH_FAILED code. That asymmetry is out of scope for this issue’s initial-resolution stack and was not changed.
  • Audio loading/lifecycle owned by other agents; this work stayed on provider resolution/refresh classification.

Sentry

Issue: https://avoidquest.sentry.io/issues/RADIO-25

No Fixes RADIO-25 — root defect not fixed because none was demonstrated in application code.

Open in Web Open in Cursor 

Summary by cubic

Adds regression tests that lock in the YouTube provider failover behavior behind RADIO-25. No production code changes; the new tests confirm the existing contract: pooled HTTP 500 and network/CORS failures aggregate into YouTubeProviderAggregateError and surface as YOUTUBE_CLIENT_RESOLUTION_FAILED, while recovery when a later provider succeeds still works.

  • Covers provider failover, client pool exhaustion, loader diagnostics, stream-refresh onFailed, and error_expected=false reporting.
  • Sentry visibility for curated relay outages stays as-is; DJ refresh still throws into onFailed but deck reporting maps it to PLAY_ERROR (unchanged).