diff --git a/docs/production-incident-baseline.md b/docs/production-incident-baseline.md index d37d91b557..41874d2f30 100644 --- a/docs/production-incident-baseline.md +++ b/docs/production-incident-baseline.md @@ -7,6 +7,33 @@ full incident log or a replacement for runbooks. Use it to build shared memory about the kinds of issues this system encounters, the signals that identified them, and the durability work they suggest. +## 2026-08-10: Peloton workouts omitted `total_work` + +- **Status:** Root cause identified and fixed in this workspace; deployment and + post-deploy Sentry verification remain pending. +- **Symptoms / user impact:** Peloton workout syncs failed with + `PelotonResponseError: Peloton returned an invalid workouts response`, so + affected sync runs could not ingest the returned workout page. The issue had + 64 occurrences and no directly affected Sentry users. See + [DOFEK-SERVER-5E](https://east-bay-software.sentry.io/issues/DOFEK-SERVER-5E/). +- **Evidence:** The latest event's Zod errors identify + `data[6]` through `data[19].total_work` as `undefined`; the failure occurs + while parsing the successful `/api/user/{userId}/workouts` response in + `packages/peloton-client/src/client.ts`. Existing Sentry error reporting + captured the complete validation paths, so no additional diagnostic + instrumentation was required. +- **Root cause:** `pelotonWorkoutSchema` accepted `total_work: null` but still + required the property to be present. Peloton omits that field for some + workout records, making the schema stricter than the observed API contract. +- **Fix:** Changed `total_work` to `z.number().nullish()` and added a client + regression test covering a workout response where Peloton omits the field. +- **Validation:** The red regression test failed with the same Zod validation + path reported by Sentry; after the schema change, the Peloton client and + parser suites passed (18 tests). +- **Remaining risk / follow-up:** Deploy the fix and verify that + `DOFEK-SERVER-5E` stops receiving new events. No retry, timeout, or fallback + was added because the root cause was a local response-contract mismatch. + ## 2026-08-10: Pull-request CI failures from configuration and test drift - **Status:** Repository fixes are pushed; the latest CI run has no failed diff --git a/packages/peloton-client/src/client.test.ts b/packages/peloton-client/src/client.test.ts index c9097761eb..9c15383bc8 100644 --- a/packages/peloton-client/src/client.test.ts +++ b/packages/peloton-client/src/client.test.ts @@ -154,6 +154,34 @@ describe("PelotonClient", () => { await expect(client.getWorkouts()).resolves.toEqual(response); }); + it("accepts workouts where Peloton omits total work", async () => { + const response = { + data: [ + { + id: "workout-2", + status: "COMPLETE", + fitness_discipline: "strength", + created_at: 1_709_280_000, + start_time: 1_709_280_000, + end_time: 1_709_281_800, + is_total_work_personal_record: false, + }, + ], + total: 1, + count: 1, + page: 0, + limit: 20, + page_count: 1, + sort_by: "-created_at", + show_next: false, + show_previous: false, + }; + const responses = [Response.json({ id: "user-123" }), Response.json(response)]; + const client = new PelotonClient("secret", async () => responses.shift() ?? Response.error()); + + await expect(client.getWorkouts()).resolves.toEqual(response); + }); + it("accepts numeric performance summaries (DOFEK-SERVER-5F)", async () => { const graph = { duration: 5, diff --git a/packages/peloton-client/src/types.ts b/packages/peloton-client/src/types.ts index 36c4db3b7a..001bdf2361 100644 --- a/packages/peloton-client/src/types.ts +++ b/packages/peloton-client/src/types.ts @@ -25,7 +25,7 @@ export const pelotonWorkoutSchema = z.object({ created_at: z.number(), start_time: z.number(), end_time: z.number().nullable(), - total_work: z.number().nullable(), + total_work: z.number().nullish(), is_total_work_personal_record: z.boolean(), metrics_type: z.string().nullish(), device_type: z.string().optional(),