Add additional checks for group projects

What does this MR do and why?

Add additional checks for group projects

Add fallback values for grapqhql response in case of response has some missing values

Summary of Changes

This update improves error handling in the GroupProjectsDropdown component by adding defensive programming techniques when accessing nested properties. The code now safely handles cases where the GraphQL query returns null for the group data by using optional chaining and default values. Previously, the code would crash when trying to access properties on null objects. The changes include:

  1. Removing the unused lodash 'get' import and replacing it with more modern JavaScript syntax
  2. Adding proper null checks when accessing group.projects.nodes data
  3. Simplifying the updateQuery function by directly accessing properties with optional chaining
  4. Adding a new test case to verify the component handles null group data correctly

These changes make the component more robust by preventing errors when the API returns unexpected data structures, particularly when the group property is null.

References

Screenshots or screen recordings

Description UI
Policy scope Screenshot 2025-03-12 at 17.10.25.png

How to set up and validate locally

  1. Go to Group
  2. Secure -> Policies
  3. New policy
  4. Check specific projects in policy scope

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.

Related to #524637 (closed)

Merge request reports

Loading