Skip to content

Multi-segment merge queue head_ref would not fail closed #316

Description

@tykeal

Observation

The merge_group handler extracts a pull request number from merge_group.head_ref with a single-segment match:

  • index.js:536-542 reads mergeGroup.head_ref and applies /(?:^|\/)gh-readonly-queue\/.+\/pr-(\d+)-/.
  • index.js:555 then uses parseInt(match[1], 10) as the pull request number.

If the regex does not match at all, the handler fails closed with an unrecognized-head-ref result (index.js:543-552).

Hypothetical future shape

If GitHub ever produced a merge queue ref containing multiple pr-<n>-<sha> segments, for example for a batched group, the current regex would still match and silently take only the first pull request number. The app would evaluate that one pull request and ignore the rest, instead of treating the ref shape as unrecognized and failing closed.

This is hypothetical and currently unobserved. The current code records the evidence in index.js:586-591: 251 distinct gh-readonly-queue/* refs sampled across servo/servo, randovania/randovania, NVIDIA/cuda-quantum, home-assistant/core, and grafana/grafana each had exactly one pr-<number>-<sha> segment. GitHub currently expresses batching as a chain of single-pull-request merge groups, each based on the previous group's head, which is why merge_group.base_sha is the head commit's parent.

Suggested hardening

Before extracting the pull request number, reject refs containing more than one pr-<n>-<sha> segment. That would let the existing unrecognized-head_ref guard fail closed instead of silently narrowing the scope if GitHub changes the ref format in the future.

This is defensive hardening against a possible future GitHub behavior change, not a present defect.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions