Pipeline status in MR fails if source branch has no jobs

Summary

Merging a branch with no jobs will result in Could not retrieve the pipeline status., although the target branch has jobs.

Steps to reproduce

Create a .gitlab-ci.yml with a job that only runs on master branch. Create a MR from another branch and merge it.

Example Project

https://gitlab.com/fdellwing/broken-pipeline-status

What is the current bug behavior?

Gitlab is unable to fetch the after merge pipeline status (Could not retrieve the pipeline status.)

What is the expected correct behavior?

Gitlab showing the result of the after merge pipeline.

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Results of GitLab application Check

Possible fixes