Skip to content

fix(ci): add merge-conflict labels again on jq 1.6 runners - #14136

Merged
bolichen97 merged 1 commit into
mainfrom
ci/merge-conflict-label-jq
Sep 27, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
ci/merge-conflict-label-jq

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: conflicted PRs get the "merge conflict" label again, using far fewer API calls per sweep.

The "merge conflict" label is never added any more. The Sync merge-conflict label step fails on the first conflicted PR it meets (for example run 36223713979) with jq: error: syntax error, unexpected label, then HTTP 422.

Why it matters

Reviewers scanning the /pulls list cannot see which green-looking PRs are unmergeable. Because the step dies at the first add, stale labels on resolved PRs are not removed either. The sweep is also one of the heavier users of the shared GITHUB_TOKEN pool.

Not a goal

Fixing the same jq line in pr-readiness.yml, or changing when the sweep runs.

What changed (motivation → approach → change)

Before After
jq --arg label fails on jq 1.6 jq --arg name works on 1.6 and 1.7
one gh pr view per UNKNOWN PR one wait, then one re-list
~500 API calls per sweep after a push to main ~11 calls plus the label changes

add_label() built its POST body with jq -n --arg label "$LABEL" '{labels: [$label]}'. label is a jq keyword. jq 1.7 accepts it as a variable name, but jq 1.6 does not, and the CodeBuild fleet that push runs moved to in #11880 ships jq 1.6. So jq printed nothing, gh api posted an empty body, and GitHub answered 422. The binding is now name. .github/workflows/fork-pr-label.yml has the same line; it runs on ubuntu-latest today so it works, but it gets the same rename.

GitHub computes mergeability lazily, so right after main moves almost every open PR lists as UNKNOWN. The sweep used to re-ask each of them with gh pr view. Now it first settles every PR whose state is already known. Then it waits RECHECK_DELAY_SECONDS (60) once and lists open PRs again, acting only on the ones that were UNKNOWN. Settling first means a push that cancels the run during the wait loses nothing. A PR still UNKNOWN, or a failed re-list, is left for the next sweep, the same rule as before. Only CONFLICTING adds the label and only MERGEABLE removes it.

Backwards compatibility

Compatible: the label name, triggers, and add/remove rules are unchanged; only how often GitHub is asked changed.

Tests

test/test_pr_merge_conflict_label_workflow.py runs the workflow's own script with a stubbed gh. It checks that CONFLICTING adds the label with body {"labels": ["merge conflict"]} and MERGEABLE removes it. It checks that known PRs are labelled before the second listing, that UNKNOWN costs exactly one re-list and no gh pr view, that a PR still UNKNOWN is left alone, and that a failed re-list keeps the first pass and exits 0. A static test fails if either label workflow binds a jq 1.6 keyword with --arg, so it catches the bug even where the local jq is 1.7. On origin/main four of the five tests fail (local jq is 1.6, which reproduces the exact CI error).

Manual verification

jq -n --arg label x '{labels: [$label]}' on jq 1.6 prints the CI error; jq -n --arg name x '{labels: [$name]}' prints {"labels":["x"]}. The routing, fleet-parity, scheduled-failure-watch, workflow-security and workflow-permissions test files still pass.

Related Issues

No linked issue: regression from #11880 (CodeBuild migration), found in run 36223713979.

.github/workflows/pr-readiness.yml has the same --arg label line (~L1497). Its job runs on ubuntu-latest, so it works today; it is owned by another in-flight change and is left untouched here.

Pattern harvest

Rule candidate: lint
Pattern: jq --arg/--argjson bound to a jq keyword (label, if, end, ...), which jq 1.7 accepts and jq 1.6 rejects

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and pepmach September 26, 2026 06:50
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 60c76cb826543fab79bc8efad7ae83e956ce2444 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify on one real sweep that gh pr list --json mergeable itself triggers GitHub's lazy computation — the stubbed tests can't prove that replacement nudge.

[DESIGN-REVIEWED] 60c76cb

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 60c76cb826543fab79bc8efad7ae83e956ce2444 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 60c76cb

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 60c76cb826543fab79bc8efad7ae83e956ce2444: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 60c76cb826543fab79bc8efad7ae83e956ce2444 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify on real GitHub that a bare re-list returns computed mergeability after 60s — the stub proves the flow, not GitHub's lazy-compute behaviour.

Not justified as shipped

  • Item 2 — rides along: the fork-pr-label.yml rename is not the reported defect ("it runs on ubuntu-latest today so it works") — a declared sibling of the same root cause, no premise risk, no surface of its own.

The one remaining sibling, --arg label at .github/workflows/pr-readiness.yml:1785 (grep --arg(json)? <jq-keyword>, count: 1), is declared out of goal and owned by another in-flight change — accepted-and-deferred, and the description says exactly what is left.

What this change ships

Inventory (7 items) — 6 justified

Intent: FIX — conflicted PRs get the "merge conflict" label again, at far fewer API calls per sweep; defect reproduced by tests that fail on base.

  1. Conflicted PRs are labelled again (--arg label → --arg name in the sweep) — justified
  2. Same rename in fork-pr-label.yml, which works today — rides along (declared sibling fix)
  3. UNKNOWN PRs cost one wait + re-list instead of one gh pr view each (~500 → ~11 calls, measured, in-goal) — justified
  4. Known-state PRs are settled before the wait, so a cancelled run loses nothing — justified
  5. A failed re-list warns and leaves UNKNOWN PRs for the next sweep — justified
  6. Sweep now takes ≥60s when UNKNOWNs exist (RECHECK_DELAY_SECONDS) — justified
  7. New test suite runs the sweep with stubbed gh; static test bans jq-keyword bindings in both label workflows — justified

[FIRST-PRINCIPLES-REVIEWED] 60c76cb

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 60c76cb826543fab79bc8efad7ae83e956ce2444 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 60c76cb

Verdict parsed from the review's SHA-scoped output markers for commit 60c76cb826543fab79bc8efad7ae83e956ce2444.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 60c76cb826543fab79bc8efad7ae83e956ce2444: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the ci/merge-conflict-label-jq branch from 876fe00 to 4f97430 Compare September 26, 2026 07:10
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fork-pr-label.yml rename rides along span=944a48b979a8

Disposition: accepted. The rename is the same one-line jq 1.6 keyword fix in the only other label workflow with that line; the static test pins both files. Kept in this PR on purpose.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • API-cost reduction rides along span=b1e5446bdc20

Disposition: accepted. The re-list replaces per-PR gh pr view calls that drained the shared GITHUB_TOKEN pool (the brief for this fix asked for both). A still-UNKNOWN PR or failed re-list falls back to the existing next-sweep rule, and known PRs are settled before the wait.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 26, 2026
@iamwhatever
iamwhatever force-pushed the ci/merge-conflict-label-jq branch from 4f97430 to db81b2f Compare September 26, 2026 15:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 26, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fork-pr-label.yml rename rides along span=e6b2517d371d

Disposition: accepted. Same one-line jq 1.6 keyword fix in the only other label workflow with that line; pinned by the static test. pr-readiness.yml is owned by another in-flight change and is left untouched.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • known-PR-first ordering rides along span=a8f4941f4253

Disposition: accepted. Settling known PRs before the wait is what makes the new wait safe under cancel-in-progress; pinned by the call-order assertion in the re-list test.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • RECHECK_DELAY_SECONDS knob rides along span=f0e273c6cd6f

Disposition: accepted. One consumer, same idiom as PR_LIST_LIMIT, and the tests need it set to 0 to run without a real sleep.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • failed re-list fallback rides along span=7da0ff886b2b

Disposition: accepted. Same leave-for-next-sweep rule the old per-PR view used on error; pinned by test_failed_relist_keeps_first_pass_and_exits_clean.

@iamwhatever
iamwhatever force-pushed the ci/merge-conflict-label-jq branch from db81b2f to 5a5ffb5 Compare September 26, 2026 17:52
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • list read may not trigger mergeability compute span=73d7dfd544c0

Disposition: rebutted with a measurement. Right after main moved (7b2da39 -> 1354188), gh pr list --json number,mergeable read 585 of 681 open PRs as UNKNOWN. The same list read 60s later: 0 UNKNOWN (240 CONFLICTING, 441 MERGEABLE), and again at +180s. No per-PR view was made in between, so a list read does start the computation and one 60s re-list settles them.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • re-list skips the ceiling warning span=08c7bca6bd91

Disposition: not changed. The re-list is the same query 60s after the first, which already warns at the ceiling; today's count is 681 of 900. A second warning would repeat the first.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fork-pr-label.yml rename rides along span=b55531bb8e08

Disposition: accepted. Same one-line jq 1.6 keyword fix in the only other label workflow with that line; pinned by the static test. pr-readiness.yml is owned by another in-flight change.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • one-wait-one-re-list rides along span=b3360dcf3653

Disposition: accepted. Measured on production after a push to main: 585 of 681 PRs UNKNOWN on the first list, 0 UNKNOWN on a list 60s later, with no per-PR views between (see the earlier comment on this PR).

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • known-PR-first ordering rides along span=85671ae2c0b5

Disposition: accepted. It makes the wait safe under cancel-in-progress; pinned by the call-order assertion in the re-list test.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • failed re-list fallback rides along span=852f62cae380

Disposition: accepted. Same leave-for-next-sweep rule as before; pinned by test_failed_relist_keeps_first_pass_and_exits_clean.

@iamwhatever
iamwhatever force-pushed the ci/merge-conflict-label-jq branch from 5a5ffb5 to b421cc3 Compare September 27, 2026 06:12
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 27, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • API-cost rework rides along span=f59769ddb7ed

Disposition: accepted. Measured after a push to main: 585 of 681 PRs UNKNOWN on the first list, 0 UNKNOWN on a list 60s later, with no per-PR views.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • sleep before settling UNKNOWN under cancel-in-progress span=62a630465217

Disposition: accepted. A merge inside the 60s cancels this run, but the run the merge starts lists again, so UNKNOWN PRs settle on that run. Known PRs are labelled before the wait, so nothing already known is lost.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • pr-readiness.yml still has --arg label span=a54cccb0fee5

Disposition: accepted-and-deferred. That job runs on ubuntu-latest (jq 1.7), so it works today, and another in-flight change owns pr-readiness.yml. The static test can widen to every workflow once that line is fixed.

add_label() bound the label name as `jq --arg label`. `label` is a jq keyword; jq 1.7 tolerates it as a variable name but jq 1.6 (the CodeBuild fleet's jq since #11880) rejects it, so the POST body was empty, the API answered 422, and the sweep step failed. Rename the binding to `name` here and in fork-pr-label.yml.

The sweep also spent one `gh pr view` per UNKNOWN PR, which after a push to main is most of ~500 open PRs. Replace that with a single wait-and-re-list; anything still UNKNOWN is left for the next sweep, as before.
@iamwhatever
iamwhatever force-pushed the ci/merge-conflict-label-jq branch from b421cc3 to 60c76cb Compare September 27, 2026 07:37
@iamwhatever
iamwhatever requested a review from a team as a code owner September 27, 2026 07:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 27, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on behalf of the maintainers (sweep 2026-09-27): readiness passed, required checks green on 60c76cb, no blocking review threads, security posture unchanged. Approving and merging.

@bolichen97
bolichen97 merged commit 0eefc0b into main Sep 27, 2026
102 of 110 checks passed
@bolichen97
bolichen97 deleted the ci/merge-conflict-label-jq branch September 27, 2026 16:54
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants