Backend: RuntimeError when project path has changed
Summary
When a user has a manual job that includes trigger:project
in their .gitlab-ci.yml
and the project path has changed, they'll see the following error when viewing the pipeline page:
An error occurred while fetching the pipelines jobs
The pipeline tab displays:
We are currently unable to fetch data for this pipeline
It seems that the GraphQL API is getting a 500 Internal Server error
in response to a query:
- Kibana Link
- Additional details in ZD Ticket
Sentry info
https://sentry.gitlab.net/gitlab/gitlabcom/issues/3189754/?referrer=gitlab_plugin
RuntimeError: No project! nil is not a Project
lib/gitlab/user_access.rb:154:in `assert_project!'
raise "No project! #{project.inspect} is not a Project" unless project.is_a?(::Project)
lib/gitlab/graphql/tracers/timer_tracer.rb:20:in `trace'
yield
lib/gitlab/graphql/generic_tracing.rb:40:in `with_labkit_tracing'
return yield unless Labkit::Tracing.enabled?
lib/gitlab/graphql/generic_tracing.rb:30:in `platform_trace'
with_labkit_tracing(tags, &block)
lib/gitlab/graphql/tracers/logger_tracer.rb:14:in `trace'
yield
...
(245 additional frame(s) were not displayed)
Steps to reproduce
In my testing, I found that this ONLY fails when you use when: manual
. When this is removed, it works as expected and shows Downstream project cannot be found
would be the expected behavior for the linter.
- Create an upstream project with a job:
job_1:
stage: jobs
when: manual
trigger:
project: path/to/project
branch: master
strategy: depend
- Create a downstream project at
path/to/project
with a valid job. Validate that your pipeline works. - Change the path of the project from
path/to/project
topath/to/new/project
- Run a pipeline again and observe the behavior.
Example Project
See https://gitlab.com/gitlab-gold/cbledsoe-test/multi-project-pipeline/upstream/-/pipelines/525369386
What is the current bug behavior?
Pipeline and pipeline jobs fail to load when .gitlab-ci.yml
has outdated project paths.
What is the expected correct behavior?
Pipeline and pipeline jobs should load fully or the linter should provide an error if the project path has changed and can't be followed.
Relevant logs and/or screenshots
Output of checks
GitLa.com Edition 14.11.0-pre ebfeaceb
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 should consider updates to our linter and:
- Do a check to see whether or not a project path has moved and if it has, then error or
- Allow for following path changes and redirection
Workaround
This was reviewed in a confidential issue and we found that simply updating the project path to the new path will fix this issue.