Agent creation modal fails with error "Cannot read properties of null (reading 'project')"
Summary
Agent creation modal fails with the error "Cannot read properties of null (reading 'project')" and doesn't show the agent token. The mutations work fine and the agent is indeed created. It is likely related to the addAgentConfigToStore
method which updates the Apollo cache. After investigation, the issue is with the agent_configurations
field of the agentConfigurations
query. It is expected to receive an array with the list of the agent names, but it returns null
if no configurations are present.
Steps to reproduce
- Create an empty repository with no agent configurations
- Visit Operate -> Kubernetes clusters page
- Select "Connect a cluster"
- Create a new agent from the dropdown in the agent modal
- Verify the error is shown instead of the installation instructions
Example Project
https://gitlab.com/anna_vovchenko/test-project-without-deployment-target <-- Please request access if needed
What is the current bug behavior?
While the agent and the token are successfully created, the installation instructions are not shown. Instead, an error is shown.
What is the expected correct behavior?
After successful agent creation, the installation instructions should be shown.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com /label reproduced on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: \`sudo gitlab-rake gitlab:env:info\`) (For installations from source run and paste the output of: \`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production\`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:check SANITIZE=true`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`) (we will only investigate if the tests are passing)
Possible fixes
The agent configurations resolver should return an empty array if no configurations are found.
Workaround
- Refresh the page after getting the error
- Create a new token for the agent from the agent page