Skip to content

fix-rollbar (7266/464932643616): Guard against undefined week in exercise editor#605

Open
astashovai wants to merge 1 commit into
astashov:masterfrom
astashovai:fix/rollbar-464932643616
Open

fix-rollbar (7266/464932643616): Guard against undefined week in exercise editor#605
astashovai wants to merge 1 commit into
astashov:masterfrom
astashovai:fix/rollbar-464932643616

Conversation

@astashovai

Copy link
Copy Markdown
Contributor

Summary

  • Add defensive null checks when accessing evaluatedProgram.weeks[index].days in exercise editing UI components
  • Protect against stale week/day indices that reference positions no longer existing in the re-evaluated program
  • Affected files: screenEditProgramExercise.tsx, editProgramExerciseDay.tsx, editProgramExerciseDaysList.tsx, editProgramExerciseAcrossAllWeeks.tsx, editProgramUiHelpers.ts

Rollbar

https://app.rollbar.com/a/astashov/fix/item/liftosaur/7266/occurrence/464932643616

Decision

Fixed — the error has 230 occurrences in production on Android, affects normal user flows (editing exercise programs), and the fix is minimal defensive null checking.

Root Cause

When a user edits a program exercise on Android (React Native), state changes can cause the evaluated program to be recomputed with a different week/day structure. Components that access evaluatedProgram.weeks[index].days without null guards crash with "Cannot read property 'days' of undefined" when the index points to a week that no longer exists in the re-evaluated program.

Test plan

  • Edit a program exercise with multiple weeks
  • Delete a week while on the exercise editing screen
  • Verify no crash occurs and the UI recovers gracefully
  • Unit tests pass (804 passing)
  • Build succeeds

…cise editor

Add defensive null checks when accessing evaluatedProgram.weeks[index].days
in the exercise editing UI. The crash occurs when the program structure changes
during editing (e.g. via onChange handlers) and stale week/day indices reference
positions that no longer exist in the re-evaluated program.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant