Skip to content

[BUG] Label workflow removes has-conflicts on unknown mergeability when CI passes #2045

Closed

Description

@edelauna

Problem

The label workflow removes has-conflicts from a PR that still has merge conflicts. The label comes back on a later run, so it flaps.

Context

GitHub returns mergeable: null and mergeable_state: "unknown" for a short time after each push to main. #2028 keeps has-conflicts for unknown mergeability only inside the CI-pending and CI-failed branch. Other paths do not handle it.

  • The early conflict check matches only mergeable === false && mergeable_state === 'dirty'. Unknown mergeability passes it.
  • When CI passes, the workflow checks mergeability again only if desiredLabel === 'awaiting-maintainer'.
  • For any other result (awaiting-coderabbit, awaiting-author, no label), nothing handles unknown. reconcileLabels(pr, desiredLabel) removes every state label that is not the desired one. has-conflicts is in that list.

Evidence from production: after #1739 and #2028, has-conflicts fell from 85 to 47 in about two hours and recovered to 76. 28 of the 41 PRs that lost it still conflict with main (tested with git merge-tree). The log for #1597 at 2026-10-13 01:36 UTC ends with CI passing, reviews=1, coderabbit=pending, maintainer=pending, blockers=0 → (none) and has no "mergeability pending" line. #1597 was labeled and unlabeled four times in two hours.

GitHub documents that mergeable is null while a background job computes it.

Reproduction steps

  1. Use the workflow test harness on origin/main.
  2. Run runWorkflow({ mergeable: null, mergeableState: "unknown", labels: ["has-conflicts"] }). CI passes by default.
  3. Read the label calls.

Expected result

The PR keeps has-conflicts while mergeability is unknown.

Actual result

has-conflicts is removed. awaiting-coderabbit and coderabbit-review-active are added. The log line is PR #1437: CI passing, reviews=0, coderabbit=pending, maintainer=pending, blockers=0 → awaiting-coderabbit.

Proposed fix

  1. Handle unknown mergeability once, before the CI branch and before the final reconcileLabels. When mergeability is unknown and the PR has has-conflicts, keep it. Do not add it.
  2. Remove the duplicate unknown handling in the CI branch and in the awaiting-maintainer branch.
  3. Add a test for the CI-passing case above. Keep the [Fix] Label workflow strips has-conflicts when mergeability is unknown #2028 tests.
  4. Log mergeable and mergeable_state in the decision line, so the next case names its cause.

File: .github/workflows/label-pr-review-state.yml. Tests: src/services/__tests__/pr-review-state-workflow.test.ts.

Related: #2025, #2028.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions