Guard blob name in highlight mixin against null
What does this MR do and why?
When a blob's name comes back null from the getBlobInfo GraphQL query (the RepositoryBlob.name field is explicitly nullable in the schema), the unguarded name.endsWith(extension) call in initHighlightWorker throws a TypeError. This crashes the blob page's highlighting/blame setup before any early return can happen.
This MR adds a null guard so the extension lookup is skipped when name is missing, matching the nullable schema contract.
Root cause
Introduced in !174877 (merged) (glimmer highlighting), which added the unguarded name.endsWith(extension) call when scanning FILE_EXTENSION_MAPPING_HLJS.
References
- Resolves https://gitlab.com/gitlab-org/gitlab/-/work_items/629946
- Sentry issue:
TypeError: Cannot read properties of undefined (reading 'endsWith')atapp/assets/javascripts/repository/mixins/highlight_mixin.js:54
Screenshots or screen recordings
N/A — this is a crash fix in highlighting logic with no visible UI change.
How to set up and validate locally
- Run the Jest spec:
npx jest spec/frontend/repository/mixins/highlight_mixin_spec.js - Confirm the two new
when the blob has no namecases pass (they assertinitHighlightWorkerdoes not throw whennameisnull/undefined).
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.