Skip reference existence check for child pipelines (behind FF)

What does this MR do and why?

Fixes a bug in which child pipelines on deleted refs would fail with a Reference not found error, despite jobs starting just fine within the same parent pipeline.

A common example is any sort of pipeline on a merged MR, where the associated reference has frequently been deleted (whether it be the source branch or a refs/merge-requests/* ref).

The change here is to handle child pipelines like similar to jobs, and simply skip the reference existence check for child pipelines, because the parent pipeline will already have performed it and preserved the associated commit with a keep-around reference (i.e. refs/keep-around/<sha>).

References

Screenshots or screen recordings

Before After
Screenshot_2025-09-10_at_14.35.28 Screenshot_2025-09-10_at_14.35.51

How to set up and validate locally

Create a project with the following CI configuration, and configure it to use merged results pipelines:

# .gitlab-ci.yml
workflow:
  rules:
    - if: $CI_MERGE_REQUEST_IID
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

test:
  script: exit 0

manual_trigger:
  trigger:
    include:
      - local: ci/child.gitlab-ci.yml
  when: manual

and

# ci/child.gitlab-ci.yml
workflow:
  rules:
    - if: $CI_MERGE_REQUEST_IID
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

test:
  script: exit 0

Then:

  1. Enable the feature flag skip_reference_existence_check_for_child_pipelines
  2. Run a merged results pipeline with a child pipeline
  3. Merge the merge request
  4. To speed things up, run merge_request.cleanup_refs in rails console (otherwise it is async and can take a while)
  5. Verify that the MR pipeline's refs/merge-requests/:iid/merge has been deleted (merge_request.project.commit(merge_request.merge_ref_path) should return nil; make sure to check on a clean cache)
  6. Trigger the child pipeline's manual job

With skip_reference_existence_check_for_child_pipelines disabled: The job fails with a Reference not found error

With skip_reference_existence_check_for_child_pipelines enabled The job succeeds and creates a child pipeline.

To verify parity with jobs, you can add a simple manual job to the pipeline and see it behaves the same way:

manual:
  script: exit 0
  when: manual

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Hordur Freyr Yngvason

Merge request reports

Loading