Skip to content

UC-026.4: Edge Cases & Error Handling โ€‹

๐Ÿ“– 1. Context & Problem Statement โ€‹

  1. Distance Recalculation Integrity: Manual distance overrides or retroactively reassigning bikes for Strava activities must dynamically modify the affected frames' totalKm to avoid cumulative discrepancies.
  2. Ghost Bikes & Onboarding: Missing gear/bike references in Strava activities block synchronization. We need a wizard to map untracked frames immediately.
  3. Indoor/Trainer GPS Lack: Activities recorded indoors do not possess GPS polyline geometry, requiring disabled map controls and helpful tooltips to prevent drawing errors.
  4. Token Revocation Security: If a user revokes Strava access, subsequent syncs fail with 401 Unauthorized. The app must gracefully purge credentials and guide the user to relink.

โš™๏ธ 2. Backend Logic & API (apps/api) โ€‹

  1. PATCH /api/strava/activities/:id/reassign:
    • Accepts payload { newLocalBikeId: string } for CONFIRMED activities.
    • Transactional: subtracts activity distance from old bike's totalKm and adds it to new bike's totalKm.
  2. PATCH /api/strava/activities/:id/distance:
    • Accepts payload { newDistance: number } (meters) for CONFIRMED activities.
    • Transactional: calculates distance delta and updates the assigned bike's totalKm safely.
  3. 401 Purge Interceptor:
    • Catches expired/revoked 401 Unauthorized token responses, clears the user's Strava tokens, and resets credential records in the database.

๐ŸŽจ 3. User Interface (apps/web) โ€‹

  1. Indoor Workouts: Displays "No GPS Data Available" banners and disables "Map Route" buttons with customized hover-tooltips for virtual rides lacking geometry.
  2. Ghost Bike Resolver: Clicking "[ โž• Import New Bike ]" inside the frame selection dropdown opens the SmartMappingWizardModal to import missing bikes from Strava on the fly.

๐Ÿงช 4. Testing Requirements โ€‹

  • Integration Tests: Verify reassignment and distance math transaction locks. Test token purge workflows.