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
hasRenderErrorcrash (viewerisundefined)** #625059. fixed with optional chaining —this.viewer?.renderErrorprojectInfoqueryupdatehook crash**. fixed by defaulting the parameter:update({ project } = {}). same guard was already applied to the EE subclass of this component in !252546 (merged).
References
- Issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/625059
- Sentry: https://new-sentry.gitlab.net/organizations/gitlab/issues/3696061/
- Audit of this error class across
group::source codefrontend: gitlab-org#23447 (comment 3764413057)
Screenshots or screen recordings
The video shows four scenarios in order:
- File actions menu on the rendered Markdown viewer — opens normally.
- Menu after switching to the source viewer — opens normally.
getBlobControlsresponse modified to return no blob nodes — menu still renders and opens with no consoleTypeError.getProjectInforequest 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
-
Visit a blob page on GDK, for example
https://gdk.test:3443/gitlab-org/gitlab-test/-/blob/master/README.md. -
Open the File actions menu (top-right of the file header). Confirm it opens in both rendered (rich) view and source view.
-
To reproduce the
getBlobControlsfailure path: use browser devtools request blocking (or any interception tool) to block or return an emptygetBlobControlsGraphQL response. Reload the page and confirm the File actions menu still renders and opens with noTypeErrorin the console. -
To reproduce the
getProjectInfofailure path: block or fail thegetProjectInfoGraphQL operation. Confirm the page shows an error alert but the File actions menu still renders and opens. -
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.