gitlab webhook payload ref conflicts with pipeline trigger api

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

webhooks are supposed to be used to trigger pipelines: docs.gitlab.com/ee/ci/triggers/#using-webhook-payload-in-the-triggered-pipeline

trigger api accepts ref parameter to run a pipeline for certain branch:

curl --request POST \
     --form token=TOKEN \
     --form ref=main \
     .../api/v4/projects/9/trigger/pipeline"

Webhook payload has a ref property, that states from what ref it was triggered:

{
  "object_kind": "push",
  "event_name": "push",
  "before": "972f566cba6d725b6079c8cc2166bd523dd3c8e2",
  "after": "5df16ebcac9c54999ce606523694f77cf705db65",
  "ref": "refs/heads/v3",
  "checkout_sha": "5df16ebcac9c54999ce606523694f77cf705db65",
  "message": null,
  "user_id": 1,
  ....
}

As a result, when a webhook is triggering a pipeline in another project, it's ref property is treated by trigger api as a ref parameter for target branch, resulting in webhooks sent not from main ref fail with {"message":{"base":["Reference not found"]}} error.

What will happen if add ref to trigger url (.../api/v4/projects/9/ref/master/trigger/pipeline)?

Payload will be broken: Снимок_экрана_2021-12-09_в_22.06.43 Снимок_экрана_2021-12-09_в_22.09.06

This makes literally impossible to use webhooks with external build pipeline for branches other then master

Edited by 🤖 GitLab Bot 🤖