fix-rollbar (7266/464932643616): Guard against undefined week in exercise editor#605
Open
astashovai wants to merge 1 commit into
Open
fix-rollbar (7266/464932643616): Guard against undefined week in exercise editor#605astashovai wants to merge 1 commit into
astashovai wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
evaluatedProgram.weeks[index].daysin exercise editing UI componentsscreenEditProgramExercise.tsx,editProgramExerciseDay.tsx,editProgramExerciseDaysList.tsx,editProgramExerciseAcrossAllWeeks.tsx,editProgramUiHelpers.tsRollbar
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].dayswithout 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