Protect against JSON.parse potentially failing
What does this MR do and why?
For #536089 (closed)
Wraps a JSON.parse
call in a try
/catch
to prevent against a null-ish value causing a fatal error.
See the commit message for more, but this shouldn't be possible during normal operation of the app, we're just adding a safeguard.
References
- This closes a followup issue, which came from: !187457 (merged)
Screenshots or screen recordings
No visual changes.
How to set up and validate locally
It's not really possible to test this using the UI, as it can't really happen under normal circumstances.
One way to do it would be to:
- open the reviewer dropdown,
- then - ensuring the dropdown doesn't close - modify
sessionStorage
so that the key points to invalid JSON data (like"#"
), - and then un-freeze the UI and select a reviewer.
For this to work, you only need to prevent the dropdown from closing, since having to re-open it would overwrite your injected data.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Thomas Randolph