Loading
Guard against undefined data in blob viewer Apollo handlers
What does this MR do and why?
Adds guard against undefined data in two places in blob viewer:
result({ data })hook for theblobInfoquery can be called withundefineddata. according to https://gitlab.com/gitlab-org/gitlab/-/work_items/625054, this error hit 114,415 events affecting 110,907 users in approximately one day- adding fallback
{ }value inupdatehook
References
- Sentry-mirrored work item: https://gitlab.com/gitlab-org/gitlab/-/work_items/625054
- Sentry issue GITLABCOM-CLIENTSIDE-2M1B3: https://new-sentry.gitlab.net/organizations/gitlab/issues/3882965/
Screenshots or screen recordings
No visible UI change — this is a defensive guard only. The table below shows that blob pages continue to work correctly after the fix (rich viewer README, source toggle, JS file with syntax highlighting, line-hash navigation, blame view).
| Before | After |
|---|---|
| No visual change (defensive guard) |
How to set up and validate locally
- Start GDK.
- Visit a blob page, for example
http://gdk.test:3000/flightjs/Flight/-/blob/master/README.md. - Toggle between Code and Preview views and confirm the content renders without errors.
- Visit a code file (e.g. a
.jsfile) and verify syntax highlighting works. - Append
#L20to the URL and confirm the page scrolls to and highlights the correct line. - Open the Blame view and confirm it loads correctly.
- Check the browser console — confirm no
TypeError: Cannot read properties of undefined (reading 'project')appears. - Run the unit tests:
yarn jest spec/frontend/repository/components/blob_content_viewer_spec.jsMR 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