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:
- Removing the unused lodash 'get' import and replacing it with more modern JavaScript syntax
- Adding proper null checks when accessing group.projects.nodes data
- Simplifying the updateQuery function by directly accessing properties with optional chaining
- 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 | ![]() |
How to set up and validate locally
- Go to Group
- Secure -> Policies
- New policy
- 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)
