Repository navigation
[Fix] Review-state labels missing on new PRs because GitHub rejects the label workflow - #2088
Conversation
…itHub accepts the workflow GitHub rejects a workflow that lists its own name in workflow_run.workflows, so no schedule, pull_request_target, issue_comment, or workflow_run runs of 'Label PR review state' started since PR #2049 merged. - Remove 'Label PR review state' from its own workflow_run.workflows list. - Remove the workflow_run.name loop-guard clause from the resolve and reconcile job if conditions and from the resolve script. - Move the privileged fork pull_request_review follow-up (issue #2046) into a new workflow, label-pr-review-state-fork-review-followup.yml, which listens for completed 'Label PR review state' runs, keeps the one-hop loop guard on workflow_run.event == 'pull_request_review', resolves fork PRs by exact head owner, branch, and SHA, and dispatches the reconciliation workflow's existing workflow_dispatch entrypoint. - Add workflow-self-listen.test.ts, which fails when any workflow lists its own name in workflow_run.workflows (actionlint does not catch this), and wire it plus the new follow-up workflow tests into the test:workflow suite. Closes #2086
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Review statusThis PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging. Current step: Wait for required CI checks; awaiting-maintainer requires CI and automated review completion. Review-state labels are managed by this workflow; do not edit them manually. |
Related GitHub Issue
Closes: #2086
Description
GitHub rejects
.github/workflows/label-pr-review-state.ymlonmain: "Workflow 'Label PR review state' cannot listen to itself." PR #2049 added the workflow's own name to itsworkflow_run.workflowslist. Since then, noschedule,pull_request_target,issue_comment, orworkflow_runrun of the workflow has started, so new PRs get no review-state labels.This PR implements the fix proposed in the issue:
"Label PR review state"from the workflow's ownworkflow_run.workflowslist.workflow_run.name != 'Label PR review state'guard clause from theif:conditions of theresolveandreconcilejobs, and the matching loop-guard block from the resolve script.pull_request_reviewruns (issue Fork PR review events leave labels stale until the hourly sweep #2046) into a new workflow,.github/workflows/label-pr-review-state-fork-review-followup.yml("Label PR review state fork review follow-up"). It listens for completed runs of "Label PR review state", accepts only runs triggered bypull_request_review, resolves fork PRs by exact head owner, branch, and SHA, and dispatches the existingworkflow_dispatchentrypoint oflabel-pr-review-state.ymlwith the PR number. The dispatched run reconciles and writes the labels with a privileged token.src/services/__tests__/workflow-self-listen.test.ts. It parses every workflow file and fails when a workflow lists its own name inworkflow_run.workflows.actionlintdoes not catch this, so a dedicated check is needed. The test runs in the existingtest:workflowCI step, together with new tests for the follow-up workflow.Design notes for reviewers:
workflow_dispatch, so their completion is filtered out by theworkflow_run.event == 'pull_request_review'gate. The gate sits in the jobif:and in the script, matching the defense-in-depth pattern of the main workflow.actions: writeandpull-requests: read; every other permission stays atnone. This preserves the security posture from issue Fork PR review events leave labels stale until the hourly sweep #2046.workflow_dispatchentrypoint. The alternative (copying the resolve and reconcile jobs into the second workflow) would duplicate about 800 lines of inline script.workflow_dispatchonce, and set theSTALE_DRY_RUNrepository variable tofalsewhen the stale clock is ready to write.Test Procedure
pnpm --dir src run test:workflowpasses: 297 tests in 4 files, including the new self-listen guard and the new follow-up workflow tests."Label PR review state"is added back to its ownworkflow_run.workflowslist (verified with a temporary edit, then reverted).actionlint1.7.7 passes on all 13 workflow files, including the fixed workflow and the new follow-up workflow.pnpm --dir src run check-typesand ESLint with--prune-suppressions --max-warnings=0pass on the changed files.pnpm testat the repository root passes (13/13 turbo tasks).Reviewers can repeat the workflow tests with:
pnpm --dir src run test:workflow.Pre-Submission Checklist
Visual Snapshots
Not applicable. This PR changes CI workflow behavior only; there is no rendered UI state to snapshot.
Videos (interaction / animation only)
Not applicable. No interaction or animation changed.
Documentation Updates
Additional Notes
A workflow rename note for reviewers: the follow-up workflow keys on the name
"Label PR review state"in itsworkflow_run.workflowslist. A rename of the main workflow must update that list entry. The new self-listen test does not catch a stale cross-workflow name; it only blocks self-references.Get in Touch
0x7777777_ on Discord