Guard blob overflow menu against missing viewer and project data

What does this MR do and why?

Fixes two crash guards in blob_overflow_menu.vue

  1. hasRenderError crash (viewer is undefined)** #625059. fixed with optional chaining — this.viewer?.renderError
  2. projectInfo query update hook crash**. fixed by defaulting the parameter: update({ project } = {}). same guard was already applied to the EE subclass of this component in !252546 (merged).

References

Screenshots or screen recordings

The video shows four scenarios in order:

  1. File actions menu on the rendered Markdown viewer — opens normally.
  2. Menu after switching to the source viewer — opens normally.
  3. getBlobControls response modified to return no blob nodes — menu still renders and opens with no console TypeError.
  4. getProjectInfo request failing — the page shows an error alert, but the menu still renders and opens.

Recorded on GDK with browser request interception to simulate both failure paths.

How to set up and validate locally

  1. Visit a blob page on GDK, for example https://gdk.test:3443/gitlab-org/gitlab-test/-/blob/master/README.md.

  2. Open the File actions menu (top-right of the file header). Confirm it opens in both rendered (rich) view and source view.

  3. To reproduce the getBlobControls failure path: use browser devtools request blocking (or any interception tool) to block or return an empty getBlobControls GraphQL response. Reload the page and confirm the File actions menu still renders and opens with no TypeError in the console.

  4. To reproduce the getProjectInfo failure path: block or fail the getProjectInfo GraphQL operation. Confirm the page shows an error alert but the File actions menu still renders and opens.

  5. Run the Jest spec:

    yarn jest spec/frontend/repository/components/header_area/blob_overflow_menu_spec.js

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.

Edited by Chaoyue Zhao

Merge request reports

Loading
Loading