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 nil instead of raising exceptions for invalid JSON
  • Prevents application crashes from malformed input
  • Follows GitLab's coding standards

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

  1. Verify the code handles valid JSON correctly
  2. Verify the code handles invalid JSON gracefully (returns nil instead 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! 🎉

Merge request reports

Loading