Error "Cannot read properties of null (reading 'project')" is shown when installing GitLab Agent from the Agent tab

Summary

Error Cannot read properties of null (reading 'project') is shown when installing Agent from the Agent tab.

Steps to reproduce

  • create an empty test project
  • in this project, create an empty file .gitlab/agents/agent001/config.yaml
  • go to Infrastructure > Kubernetes clusters, switch to Agent tab and click Connect with the GitLab Agent, select agent001 in the list and click Register

Example Project

https://gitlab.com/gitlab-gold/atanayno-kas-test

What is the current bug behavior?

The following error is shown when doing it in Chrome:

Failed to register an agent
Cannot read properties of null (reading 'project')

In Firefox it is a bit different:

Failed to register an agent
t is null

What is the expected correct behavior?

You should be able to reach the next step, obtain the registration token, and the command to install the Agent.

Relevant logs and/or screenshots

agent_error

No errors are shown in the browser's dev console.

Output of checks

This bug happens on GitLab.com. I was not able to reproduce this issue with a self-managed instance of GitLab 14.7.3

Workaround

It works fine if you create an Agent from the tab All