[mobile] Diagnose mobile tRPC non-JSON responses

Merged
AS
5mo ago
+176-0

Adds a mobile tRPC fetch wrapper that fails before JSON parsing when the server returns a non-JSON response. The thrown error includes the tRPC path, HTTP status, and a short body preview so Sentry can show the real upstream failure for WHOOP BLE background uploads. Documents the production incident baseline and current remaining risk.

Summary by Sourcery

Add a mobile tRPC fetch wrapper that surfaces non-JSON responses for WHOOP BLE uploads and document the related production incident and diagnostic mitigation.

New Features:

  • Introduce a mobile tRPC fetch wrapper that validates JSON responses and throws diagnostic errors for non-JSON tRPC responses before JSON parsing.

Enhancements:

  • Wire the mobile tRPC client to use the new fetch wrapper so WHOOP BLE background uploads report detailed response diagnostics.

Documentation:

  • Document the 2026-06-04 mobile WHOOP BLE tRPC non-JSON response incident, including symptoms, impact, mitigation, and remaining risk.

Summary by cubic

Adds a mobile tRPC fetch wrapper that fails early on non-JSON responses and throws a clear error with the tRPC path, HTTP status, content type, and a short body preview. This lets Sentry show the real upstream error during WHOOP BLE background uploads.

  • New Features
    • Added createTrpcFetch in packages/mobile/lib/trpc-fetch.ts; JSON responses pass through unchanged.
    • Handles relative tRPC URLs, absent content-type, and keeps diagnostics if the body preview can’t be read.
    • Wired into the mobile tRPC client in packages/mobile/app/_layout.tsx, with unit tests in packages/mobile/lib/trpc-fetch.test.ts, and incident details in docs/production-incident-baseline.md.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling for mobile uploads that fail due to non-JSON responses. Users now receive clearer diagnostic messages including HTTP status and response details for improved troubleshooting.
  • Documentation

    • Added production incident baseline documentation detailing past mobile upload failures and mitigation strategies.