TypeError: "t.vulnerabilities is undefined" in dependencies page
Summary
Error TypeError: "t.vulnerabilities is undefined" in console, no dependencies scanning results is shown, This bug happens on GitLab.com
Steps to reproduce
visit using firefox:
https://gitlab.com/gitlab-org/gitlab/-/dependencies
or:
https://gitlab.com/almtoolbox/hamagen-ci/-/dependencies
open console (click F12), see the error.
TypeError: "t.vulnerabilities is undefined"
anyDependencyHasVulnerabilities https://assets.gitlab-static.net/assets/webpack/pages.projects.dependencies.index.f453f92e.chunk.js:1
anyDependencyHasVulnerabilities https://assets.gitlab-static.net/assets/webpack/pages.projects.dependencies.index.f453f92e.chunk.js:1
Implementation plan
- Handle the case the API response might not define
dependencies[].vulnerabilities, if the user doesn't have the necessary permissions. This means either:- using optional chaining when attempting to access it, or
-
transforming the API response to ensure that if
dependencies[].vulnerabilitiesisn't defined, it's set to an empty array
The above could equally be done on the backend, but that's not obviously easier or better.
Edited by Mark Florian