fix: handle rejected help requests

What does this MR do and why?

Fixes an issue where the Request help action on the Manage Merge Request page fails to emit an error when the API request is rejected.

Previously, Axios rejected non-2xx responses (such as HTTP 403), causing the request to exit before reaching the existing error-handling logic. As a result, the error event was never emitted.

This MR wraps the API request in a try/catch block and emits the error event when the request is rejected. It also preserves the existing behavior of redirecting after a successful response.

Closes #958 (closed)

Design and production fit

  • Handles rejected Axios requests gracefully.
  • Preserves existing behavior for successful requests.
  • Emits the error event for both rejected requests and unsuccessful response statuses.
  • Adds regression coverage for rejected API requests.

Screenshots or screen recordings

Not applicable. This change affects request error handling and does not introduce UI changes.

Before

The rejected API request was not handled, and the error event was not emitted.

After

Rejected API requests are caught, and the error event is emitted.

Validation steps

  1. Run the HelpAction component tests:
    yarn test app/javascript/common/components/HelpAction.spec.js
  2. Verify that all 6 tests pass.
  3. Run ESLint on HelpAction.vue and HelpAction.spec.js.
  4. Verify git diff --check passes.

Validation completed:

  • 6/6 tests passed.
  • ESLint passed.
  • git diff --check passed.

/cc @leetickett-gitlab

Merge request reports

Loading
Loading