Default agent config folders when a project has no tree
What does this MR do and why?
Fixes an uncaught TypeError on the Operate > Kubernetes clusters page when a project has no repository, for example a project with no commits.
The clusters list component app/assets/javascripts/clusters_list/components/agents.vue runs three Apollo queries: agents, sharedAgents, and treeList. The tree query reads the .gitlab/agents/ folders from the default branch, to show which agents have a config folder.
For a project without a repository the tree query returns repository: null. The updateTreeList handler then set configFolders to undefined and skipped the rest behind an if. When the agents query resolved after the tree query, updateAgentsList called updateConfigFolders(), which runs this.configFolders.filter(...). That threw TypeError: Cannot read properties of undefined (reading 'filter').
The throw happens inside an Apollo update handler. The observable library rethrows it asynchronously, so the console shows Uncaught TypeError with a stack that points at vendor.dll.bundle.js instead of the component. The catalogue guessed the certificate-based cluster pages. The source is the agents list, which is live in production.
In CI this logged the error in 12 examples across 4 spec files that visit the clusters page of a project without a repository:
spec/features/projects/clusters_spec.rbspec/features/projects/clusters/gcp_spec.rbspec/features/projects/clusters/user_spec.rbspec/features/clusters/create_agent_spec.rb
Changes made:
app/assets/javascripts/clusters_list/components/agents.vue— defaultconfigFoldersto an empty array, always re-map the agent list, and drop theifguard that the default makes unnecessaryspec/frontend/clusters_list/components/agents_spec.js— new block "when the project has no repository tree and the agents arrive afterwards". It mocks the tree query withrepository: null, delays the agents query so it resolves second, and asserts that nothing throws and the agents render without a config folder. The test reproduced the exact TypeError before the fix.
How to set up and validate locally
- Create a new blank project without a README.
- Optionally register a cluster agent for it. Without one the page shows the empty state, which is fine.
- Open Operate > Kubernetes clusters.
- Open the DevTools console. Check there is no
filterTypeError. - For a project with a repository and agents, check the agents still show their config folder.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- I have evaluated the MR acceptance checklist for this MR.
References
- Addresses one entry of #628901 (browser console error catalogue, section B)
- Errors surfaced by !255207 (closed) (feature specs fail on console errors)
- Sibling fixes from the same catalogue: !255305 (merged), !255309 (merged), !255311 (merged), !255313 (merged)