Skip to content

[Fix] Review-state labels missing on new PRs because GitHub rejects the label workflow - #2088

Merged
edelauna merged 2 commits into
mainfrom
fix/label-workflow-self-listen-3204br2qcnofk
Oct 18, 2026
Merged

edelauna merged 2 commits into
mainfrom
fix/label-workflow-self-listen-3204br2qcnofk

Conversation

@zoomote

@zoomote zoomote Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

Related GitHub Issue

Closes: #2086

Description

GitHub rejects .github/workflows/label-pr-review-state.yml on main: "Workflow 'Label PR review state' cannot listen to itself." PR #2049 added the workflow's own name to its workflow_run.workflows list. Since then, no schedule, pull_request_target, issue_comment, or workflow_run run of the workflow has started, so new PRs get no review-state labels.

This PR implements the fix proposed in the issue:

  1. Remove "Label PR review state" from the workflow's own workflow_run.workflows list.
  2. Remove the workflow_run.name != 'Label PR review state' guard clause from the if: conditions of the resolve and reconcile jobs, and the matching loop-guard block from the resolve script.
  3. Move the privileged follow-up for fork pull_request_review runs (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 by pull_request_review, resolves fork PRs by exact head owner, branch, and SHA, and dispatches the existing workflow_dispatch entrypoint of label-pr-review-state.yml with the PR number. The dispatched run reconciles and writes the labels with a privileged token.
  4. Add src/services/__tests__/workflow-self-listen.test.ts. It parses every workflow file and fails when a workflow lists its own name in workflow_run.workflows. actionlint does not catch this, so a dedicated check is needed. The test runs in the existing test:workflow CI step, together with new tests for the follow-up workflow.

Design notes for reviewers:

  • The follow-up workflow keeps the one-hop loop guard from [Fix] Fork PR review-state labels stay stale until the hourly sweep #2049. The runs it dispatches have event workflow_dispatch, so their completion is filtered out by the workflow_run.event == 'pull_request_review' gate. The gate sits in the job if: and in the script, matching the defense-in-depth pattern of the main workflow.
  • The follow-up takes no artifact input and never checks out code. It reads only PR metadata and dispatches the reconciliation workflow. Its permissions are actions: write and pull-requests: read; every other permission stays at none. This preserves the security posture from issue Fork PR review events leave labels stale until the hourly sweep #2046.
  • The follow-up skips same-repository review runs. Those runs already have a privileged token and write their labels directly.
  • The dispatch approach reuses the existing reconcile script through the workflow_dispatch entrypoint. The alternative (copying the resolve and reconcile jobs into the second workflow) would duplicate about 800 lines of inline script.
  • Two steps from the issue stay with a maintainer after merge: run workflow_dispatch once, and set the STALE_DRY_RUN repository variable to false when the stale clock is ready to write.

Test Procedure

  • pnpm --dir src run test:workflow passes: 297 tests in 4 files, including the new self-listen guard and the new follow-up workflow tests.
  • The self-listen test fails as intended when "Label PR review state" is added back to its own workflow_run.workflows list (verified with a temporary edit, then reverted).
  • actionlint 1.7.7 passes on all 13 workflow files, including the fixed workflow and the new follow-up workflow.
  • pnpm --dir src run check-types and ESLint with --prune-suppressions --max-warnings=0 pass on the changed files.
  • The full pnpm test at the repository root passes (13/13 turbo tasks).

Reviewers can repeat the workflow tests with: pnpm --dir src run test:workflow.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I reviewed my own code with care.
  • Writing Style: The PR title and description use Simplified Technical English (ASD-STE100): short sentences, plain words, active voice, one idea per sentence, no contractions.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): Not applicable. This PR changes GitHub Actions workflows and their tests only; no UI changed.
  • Documentation Impact: I checked if my changes need documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I read and agree to the Contributor Guidelines.

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

  • No documentation updates are required. This is a GitHub Actions workflow change only; no Zoo Code product functionality changed.

Additional Notes

A workflow rename note for reviewers: the follow-up workflow keys on the name "Label PR review state" in its workflow_run.workflows list. 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

…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
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1
  • coderabbit-review-active

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: Zoo-Code-Org/Zoo-Code/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 03a4bfe9-4196-4693-b14b-a27e5fc3381b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna
edelauna marked this pull request as ready for review October 18, 2026 02:54
@edelauna
edelauna enabled auto-merge October 18, 2026 02:55
@github-actions

Copy link
Copy Markdown
Contributor

Review status

This 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. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@edelauna
edelauna added this pull request to the merge queue Oct 18, 2026
Merged via the queue into main with commit e4e112e Oct 18, 2026
17 of 18 checks passed
@edelauna
edelauna deleted the fix/label-workflow-self-listen-3204br2qcnofk branch October 18, 2026 03:09
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.

Label PR review state workflow is invalid: it listens to itself

2 participants