-
Notifications
You must be signed in to change notification settings - Fork 347
Patch for #4225, with additional checks to prevent overwriting user config if error encountered and allow recovery for malformed configs #4272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ble before state has been updated with lesson indices
…ssing the old config
|
@zehata is attempting to deploy a commit to the modsbot's projects Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4272 +/- ##
==========================================
+ Coverage 54.52% 56.62% +2.10%
==========================================
Files 274 297 +23
Lines 6076 6924 +848
Branches 1455 1671 +216
==========================================
+ Hits 3313 3921 +608
- Misses 2763 3003 +240 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Also, while doing testing, I realized that the error occurred before writing to state, so users' configs were actually not overwritten. Nonetheless, I think it would make more sense to add checks to explicitly ensure that users' configs are not overwritten when errors are encountered. |
| } = await Promise.resolve( | ||
| migrateSemTimetableConfig(semTimetableConfig, taModulesConfig, getModuleSemesterTimetable), | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the Promise.resolve needed? I don't think migrateSemTimetableConfig is async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I am using it to end validation early if an error occurs during migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course there are other ways of achieving the same effect
leslieyip02
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the speedy fix!
This is an extension to #4271, details of which I have copied over.
@leslieyip02 @jloh02 Patch for #4225, for the issue reported on the morning of 16 Dec by LH (https://t.me/NUSMods/13136)
Post-mortem
When the app fetches the timetable modules, it populates the lesson indices which allows the migration of the module config to the new schema
nusmods/website/src/reducers/moduleBank.ts
Lines 47 to 60 in d31261e
The issue was caused by
nusmods/website/src/views/AppShell.tsx
Lines 64 to 66 in d31261e
calling
nusmods/website/src/actions/timetables.ts
Lines 231 to 239 in d31261e
When
validateTimetable(1)is called when the app successfully fetches the module data for semester 1, it callsmigrateTimetableConfigswhich migrates the configs for all semesters, including semester 2. Since the request for semester 2 has not returned, the lesson indices has not been populated for semester 2 (see point 1). Trying to migrate the config for semester 2 will thus fail.Fix
This patch fixes this issue by removing the
migrateTimetableConfigsfunction and instead migrates each semester's timetable config as data is fetched for each of the semester.It adds checks to prevent overwriting the user's config if any error occurs during the migration process.
It also adds code to create a random config to overwrite malformed configs caused by the migration failure.