Repository navigation
Description
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-conflictsis 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
- Use the workflow test harness on
origin/main. - Run
runWorkflow({ mergeable: null, mergeableState: "unknown", labels: ["has-conflicts"] }). CI passes by default. - 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
- Handle unknown mergeability once, before the CI branch and before the final
reconcileLabels. When mergeability is unknown and the PR hashas-conflicts, keep it. Do not add it. - Remove the duplicate unknown handling in the CI branch and in the
awaiting-maintainerbranch. - Add a test for the CI-passing case above. Keep the [Fix] Label workflow strips has-conflicts when mergeability is unknown #2028 tests.
- Log
mergeableandmergeable_statein 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.
Activity
[Fix] has-conflicts label flaps off while GitHub recomputes mergeabil…
[Fix] has-conflicts label flaps off while GitHub recomputes mergeabil…