Commit Status API breaks when ref is ambiguous

Related to Commit Status API only creates branch pipelines... (#589315)

While testing the fix for the above issue I noted that detecting the ref type by using tag_exists?(ref) only works when the ref is unambiguous, if there's also a branch then we don't know if we should be creating a pipeline for the branch or tag.

The existing protected_for?(ref) check also breaks when the ref type is ambiguous.

The logic in https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/services/ci/create_commit_status_service.rb def create_pipeline needs to be modified to better detect the ref type.

Proposed solutions

  1. We need to add a new parameter to the API to allow uses to specify the ref_type which can be heads or tags.
  2. Project#protected_for needs to add ref_type so we can prevent the ambiguous error
  3. If the ref_type is passed then we can use this ref type to populate protected and tag
  4. If no ref_type is passed then we need to first check if the ref is ambiguous and then return an error message if it is (not 500)
Edited Feb 25, 2026 by Joe Woodward
Assignee Loading
Time tracking Loading