Scheduled pipeline fails quietly when target is an already merged branch
Summary
When MR is created, we can create a pipeline schedule for the branch that the MR is related to. Once the MR is merged, the scheduled pipeline still exists. (we don't have anything that would automatically indicate on the schedule page that the schedule is no longer valid) When the scheduled pipeline is being played or triggered by the schedule, the pipeline cant be created because the target (feature branch) is no longer valid.
- When triggered manually: (same when triggered on schedule, user wont see the notification then)
- From frontend perspective:
- The success notification is being shown
- Under CI/CD -> Pipelines page: no new pipelines are being displayed/added
- From backend perspective:
- The pipeline is not created.
- The error is being logged: Reference not found (kibana)
- From frontend perspective:
Steps to reproduce
- Create a MR
- Create a new scheduled pipeline and add the MR branch as the target
- Merge the MR
- Play the scheduled pipeline that was created in step 2
- Verification:
- Under CI/CD -> Pipelines: no new pipelines are visible
- Kibana logs are added
Example Project
What is the current bug behavior?
Production
What is the expected correct behavior?
Needs to be decided by UX specialist CC @v_mishra Ideally, we wouldn't show success when the pipeline is not being created.
Relevant logs and/or screenshots
Here is when I merged the MR and played the schedule pipeline, I got a success message: "Successfully scheduled a pipeline to run. Go to the Pipelines page for details."

Output of checks
I have checked this locally and on staging. This is most likely the same behaviour on gitlab.com production, but I haven't verified it myself.
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)