Skip to content

`AutocompleteController#users` should not break when `current_user` is `nil`

https://sentry.gitlap.com/gitlab/gitlabcom/issues/15375/

NoMethodError: undefined method `id' for nil:NilClass
  app/controllers/autocomplete_controller.rb:15:in `users'
    @users = @users.todo_authors(current_user.id, params[:todo_state_filter])
  lib/gitlab/request_profiler/middleware.rb:15:in `call'
    @app.call(env)
  lib/gitlab/middleware/rails_queue_duration.rb:20:in `call'
    @app.call(env)
  lib/gitlab/metrics/rack_middleware.rb:29:in `block in call'
    retval = trans.run { @app.call(env) }
  lib/gitlab/metrics/transaction.rb:49:in `run'
    yield
...
(93 additional frame(s) were not displayed)

AutocompleteController#users doesn't require an authenticated user (so that unauthenticated are able to filter by user) so we should handle current_user being nil gracefully in this action.