/api/v4/job/allowed_agents: NoMethodError: undefined method `tier' for nil:NilClass
Summary
A bizarre issue on Sentry: https://sentry.gitlab.net/gitlab/gitlabcom/issues/3434709/.
The failing code is:
environment = if persisted_environment = current_authenticated_job.persisted_environment
{ tier: persisted_environment.tier, slug: persisted_environment.slug }
end
For context, we expect it to behave like this:
irb(main):003:0> if x = {a: 1}[:a]; x; end
=> 1
irb(main):004:0> if x = {}[:a]; x; end
=> nil
i.e. it should not be possible for persisted_environment
to be nil
Steps to reproduce
Example Project
What is the current bug behavior?
What is the expected correct behavior?
Relevant logs and/or screenshots
Output 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)