Handle failed dependency location requests
What does this MR do and why?
When the dependency locations query fails, DependencyLocationCount throws an unhandled error. Its locations dropdown also stays in the searching state, so the spinner never resolves. This was split out of !240039 (merged) as a follow-up, see #603011.
This MR wraps fetchData in try/catch/finally, using the same pattern as the sibling DependencyRefCount component:
- On failure, it shows an alert: "There was a problem fetching the locations for this dependency." The error is passed to
createAlertwithcaptureError: true, so it's still reported. loadingis always reset infinally, so the dropdown stops searching whether the request succeeds or fails.
References
Closes #603011
Screenshots or screen recordings
No visual change on success. On failure, the standard danger alert appears, and the dropdown stops showing the spinner.
How to set up and validate locally
- Go to a group's Secure > Dependency list and find a dependency with locations.
- In the browser developer tools, block the GraphQL request (or make it fail), then open the locations dropdown.
- Before this change: the spinner keeps spinning and an unhandled error is logged. After this change: an alert appears and the spinner stops.
Specs: yarn jest ee/spec/frontend/dependencies/components/dependency_location_count_spec.js. All 18 tests pass. The two new failure tests fail against master.
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.