Fix NoMethodError for OrganizationClusterAgentsFinder
What does this MR do and why?
Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/1754306
NoMethodError: undefined method `can?' for nil:NilClass (NoMethodError)
return Clusters::Agent.none unless organization && user.can?(:read_organization_cluster_agent_mapping,
^^^^^
from remote_development/organization_cluster_agents_finder.rb:10:in `execute'
from resolvers/remote_development/organization/cluster_agents_resolver.rb:22:in `resolve'
Problem
User object can be nil when GraphQL endpoint is used without an authentication.
Solution
Use Ability.allowed? that can handle empty users.
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.
Edited by Vasilii Iakliushin