fix(web): prevent Previous page crash on malformed localStorage JSON#644
fix(web): prevent Previous page crash on malformed localStorage JSON#644Ashvin-KS wants to merge 1 commit into
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing this draft PR for now; I will resubmit using the required PR format/template. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the Previous page against malformed last5Quizzes data in localStorage so the page no longer crashes when JSON.parse fails, aligning behavior with Issue #643’s expected graceful recovery.
Changes:
- Wrap
last5Quizzesparsing intry/catchto preventJSON.parsefrom crashing the page. - Validate that the parsed payload is an array before using it.
- Remove the corrupted
localStoragekey and fall back to an empty quiz list on invalid data.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Why
The Previous page currently assumes last5Quizzes is always valid JSON. If the key is malformed, JSON.parse throws and the page crashes.
Fixes #643
Validation
pm --prefix eduaid_web run build (successful; existing unrelated lint warnings remain in the project)
Summary by CodeRabbit