Some users have no namespace
Summary
- Users API returns 500 response code. This is happening because some users have no namespace assigned. This only happens when an admin fires the API request.
- We need to check the number of such users and create a namespace object for them.
Steps to reproduce
- API https://staging.gitlab.com/api/v4/users/7344returns 500 response code for admin users. This is true for the same user id on production as well.
- Similarly https://staging.gitlab.com/api/v4/users/?pagination=keyset&order_by=id&sort=asc&per_page=100&created_after=2013-08-09T12:07:06.000Zwould return 500 because the response contains this user id.
Example Project
What is the current bug behavior?
What is the expected correct behavior?
Relevant logs and/or screenshots
User#shared_runners_minutes_limit delegated to namespace.shared_runners_minutes_limit, but namespace is nil: #<User id:7344 @CodLight>[ee/app/models/ee/user.rb:57:in `rescue in shared_runners_minutes_limit', ee/app/models/ee/user.rb:57:in `shared_runners_minutes_limit', grape-entity (1.0.1)[ gstg ] production> User.find(7344)
=> #<User id:7344 @CodLight>
[ gstg ] production> User.find(7344).namespace
=> nilOutput of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)
Possible fixes
We need to check the number of users that don't have namespace id and create a namespace object for them.
