api /users endpoint fails on ghost user

Summary

Customer reports failure on the API /users endpoint after upgrading from 8.17 to 10.6. I was able to reproduce the failure easily in 10.6.

https://gitlab.zendesk.com/agent/tickets/94115

Steps to reproduce

  1. Delete a user from the system, in order to trigger the "ghost" user creation
  2. get /api/v4/users

What is the current bug behavior?

Started GET "/api/v4/users" for 165.227.30.125 at 2018-04-06 20:23:21 +0000

Module::DelegationError (User#shared_runners_minutes_limit delegated to namespace.shared_runners_minutes_limit, but namespace is nil: #<User id:5 @ghost>):
  /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/ee/user.rb:21:in `rescue in shared_runners_minutes_limit'
  /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/ee/user.rb:21:in `shared_runners_minutes_limit'
  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/delegator/plain_object.rb:6:in `delegate'

Deleting the ghost user makes the problem go away.

Possible fixes

This seems to be because the ghost user doesn't have a namespace. The failing call seems to have been there since 9.3, so I'm not sure why nobody ran into this yet.

Assignee Loading
Time tracking Loading