NoMethodError: undefined method `authorized_projects' for nil:NilClass

https://sentry.gitlab.net/gitlab/gitlabcom/issues/2953033/?referrer=gitlab_plugin

NoMethodError: undefined method `authorized_projects' for nil:NilClass
  app/models/project.rb:554:in `block in <class:Project>'
    scope :visible_to_user_and_access_level, ->(user, access_level) { where(id: user.authorized_projects.where('project_authorizations.access_level >= ?', access_level).select(:id).reorder(nil)) }
  app/controllers/application_controller.rb:504:in `set_current_admin'
    return yield unless Gitlab::CurrentSettings.admin_mode
  lib/gitlab/session.rb:11:in `with_session'
    yield
  app/controllers/application_controller.rb:495:in `set_session_storage'
    Gitlab::Session.with_session(session, &block)
  lib/gitlab/i18n.rb:105:in `with_locale'
    yield
...
(159 additional frame(s) were not displayed)

Implementation Plan

  • backend Apply policy check in the EE::Projects::AutocompleteSourcesController to prevent running the auto-completion logic for not authenticated and not authorized users.
Edited by Mehmet Emin INAC