500 error for Environment deployment trigger job that is pending creation due to required deployment approval
Summary
When navigating to an environment's deployment history, clicking on a trigger job in a Waiting
state results in a 500 error. This is due to the trigger job (downstream pipeline) not being in fully created state.
- Reported by customer: Zendesk ticket (internal)
- Introduced by: !130285 (merged)
Steps to reproduce
- Create an environment
- Protect the environment with Deployment and Approver rules
- Configure a pipeline that deploys to an environment using a trigger
- Ensure a pipeline ran
- Navigate to the Environment's deployment history
- Click into the trigger job
Example Project
What is the current bug behavior?
- A 500 error occurs due to a raised exception.
What is the expected correct behavior?
- Potentially navigate to the pipeline where the trigger job exists with an alert noting that the job needs to be approved.
Relevant logs and/or screenshots
https://new-sentry.gitlab.net/organizations/gitlab/issues/667747/
NoMethodError
undefined method `project' for nil:NilClass
redirect_to project_pipeline_path(@build.downstream_pipeline.project, @build.downstream_pipeline.id)
^^^^^^^^
Possible fixes
if @build.downstream_pipeline == nil
redirect_to project_pipeline_path(@build.project, @build.pipeline.id), notice: _('Trigger job requires approval to proceed.') # Likely needs additional check to confirm if it actually needs approval
else
redirect_to project_pipeline_path(@build.downstream_pipeline.project, @build.downstream_pipeline.id)
end
Workaround
Deployment approvers can approve the deployment using the Approval options (thumbs up icon) button. Once approved, users can navigate to the associated pipeline to run the trigger job. After the job is run, the link in the no longer result in a 500 error.