CI_PIPELINE_SOURCE populating as 'push' instead of 'merge_request_event' when MR is raised and committed to

Please see the closing comment if you believe you're experiencing this bug.

Summary

Merge request event not properly being recognised by the appropriate predefined pipeline variables (e.g. $CI_PIPELINE_SOURCE == push, $CI_MERGE_REQUEST_EVENT_TYPE not populated). Really annoying and have tried many different combinations to populate the variable properly (stages, not stages, workflow rules, no rules...). Please help!!

Steps to reproduce

Parent pipeline:

stages:
 - triggers

trigger_open_pr:
  stage: triggers
  trigger:
    include: 
      - local: gitlab-pipelines/open-pr/.gitlab-ci.yml
    strategy: depend
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' 

Child pipeline example:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

job1:
 script:
  - echo $CI_PIPELINE_SOURCE

Example Project

What is the current bug behavior?

When I open a merge request and commit to the merge request source branch the variable CI_PIPELINE_SOURCE == push

What is the expected correct behavior?

When I open a merge request and commit to the merge request source branch the variable CI_PIPELINE_SOURCE should be CI_PIPELINE_SOURCE == merge_request_event

Relevant logs and/or screenshots

image image

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Version: GitLab Enterprise Edition 15.3.0-pre

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