changed Gitlab::Json.parse with Gitlab::Json.safe_parse
What does this MR do?
Replaces Gitlab::Json.parse with Gitlab::Json.safe_parse to improve error handling when parsing JSON.
Why was this MR needed?
Gitlab::Json.safe_parse is the recommended method for parsing JSON in GitLab because it:
- Returns
nilinstead of raising exceptions for invalid JSON - Prevents application crashes from malformed input
- Follows GitLab's coding standards
Related issue
Closes #586098 Fix Gitlab/JsonSafeParse: lib/tasks/gitlab/background_migrations.rake
Part of my contributor onboarding: gitlab-community/community-members/onboarding#3743
How to test
- Verify the code handles valid JSON correctly
- Verify the code handles invalid JSON gracefully (returns
nilinstead of crashing)
Author's checklist
- I have followed the Contribution Guidelines
- I have tested my changes locally
- I have added/updated tests if needed
- I have checked that no existing code depends on the exception being raised
First-time contributor
This is my first contribution to GitLab!