Epic errors when loading child issues and epics for signed out users

Summary

Signed out users see an error on epics and can't load child issues:

Steps to reproduce

  1. Go to an epic as a signed-out user
  2. See the error and that child issues don't load

Example Project

E.g epic on gitlab.com: https://gitlab.com/groups/gitlab-org/-/epics/6033

What is the current bug behavior?

What is the expected correct behavior?

Users should see issues/epics they are allowed to see.

Relevant logs and/or screenshots

Screenshot_2022-10-04_at_16.11.35

Response of the GraphQl request:

Internal server error: undefined method `events' for nil:NilClass

gitlab/app/finders/events_finder.rb:56:in `get_events' 
 gitlab/app/finders/events_finder.rb:38:in `execute' 
 gitlab/app/finders/concerns/finder_with_cross_project_access.rb:37:in `block in execute' 
 gitlab/app/finders/concerns/finder_with_cross_project_access.rb:40:in `execute' 
 gitlab/ee/app/graphql/resolvers/epics/default_project_for_issue_creation_resolver.rb:32:in `last_issue_creation_event' 
 gitlab/ee/app/graphql/resolvers/epics/default_project_for_issue_creation_resolver.rb:11:in `resolve' 
 /ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/resolver.rb:109:in `public_send' 
 /ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/resolver.rb:109:in `block (3 levels) in resolve_with_support' 
 /ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema.rb:118:in `after_lazy' 
 /ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/resolver.rb:95:in `block (2 levels) in resolve_with_support' 
 /ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema.rb:118:in `after_lazy'"

Possible fixes

Edited by Nicolas Dular