From b64f34d77cf333caa59d562aa244a191ca2c3af1 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 18 Nov 2026 14:49:25 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Accept=20pull=5Frequest=20in?= =?UTF-8?q?=20v6=20native-queue-policy=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #19100 Signed-off-by: Andy Anderson --- .github/scripts/native-queue-policy.cjs | 12 ++++++++---- .github/scripts/native-queue-policy.test.cjs | 8 ++++++++ .../fixed-19100-native-queue-policy-pull-request.md | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 changelog.d/fixed-19100-native-queue-policy-pull-request.md diff --git a/.github/scripts/native-queue-policy.cjs b/.github/scripts/native-queue-policy.cjs index b90fc0f2da..9ccadda56e 100644 --- a/.github/scripts/native-queue-policy.cjs +++ b/.github/scripts/native-queue-policy.cjs @@ -3,6 +3,10 @@ // This is an owned evidence gate, not a publisher of another App's statuses. const ACTIONS_APP_ID = 15368; const DCO_APP_ID = 1861; +// The PR-side events the gate may run on. `pull_request_target` is blocked by +// default on public repositories from 2026-12-02, so the plain `pull_request` +// event is accepted beside it. +const PR_EVENTS = ['pull_request', 'pull_request_target']; const POLICY_CHECKS = { gate: ['docker.yml', ['push', 'pull_request']], DCO: null, @@ -22,7 +26,7 @@ const SHA = /^[a-f0-9]{40}$/; const BLOCKED_LABEL = /^(hold|needs-human|release-in-progress|do-not-merge(?:\/.*)?)$/i; const MAX_QUEUE_PAGES = 10; const POLICY_CHECK_NAME = 'native-queue-policy'; -const POLICY_CHECK_SOURCE = ['native-queue-policy.yml', ['pull_request_target']]; +const POLICY_CHECK_SOURCE = ['native-queue-policy.yml', PR_EVENTS]; // Decision B on #17030: a v5→v6 forward-merge opened by v6-topup.yml carries // commits that already passed v5's DCO gate, and probot DCO cannot be repaired // PR-side. Only that exact shape may substitute prow's `dco` status. @@ -339,7 +343,7 @@ async function evaluate(args) { // A labeled/unlabeled event only matters when the label is one assertEligible // reads (BLOCKED_LABEL); every other flip cannot change the verdict. function isCosmeticLabelFlip({ eventName, payload }) { - return eventName === 'pull_request_target' && + return PR_EVENTS.includes(eventName) && ['labeled', 'unlabeled'].includes(payload.action) && typeof payload.label?.name === 'string' && !BLOCKED_LABEL.test(payload.label.name); @@ -391,7 +395,7 @@ async function replayLastVerdict({ github, context, currentCheckRunId }) { async function evaluateOnce({ github, context }) { const repo = context.repo; - if (context.eventName === 'pull_request_target') { + if (PR_EVENTS.includes(context.eventName)) { const event = context.payload.pull_request; const { data: pr } = await github.rest.pulls.get({ ...repo, pull_number: event.number }); // Post-merge label/comment edits re-fire this event; a closed PR has nothing to gate. @@ -443,7 +447,7 @@ async function evaluateOnce({ github, context }) { module.exports = { ACTIONS_APP_ID, DCO_APP_ID, POLICY_CHECKS, BUILD_CHECKS, PendingEvidence, membersForGroup, assertEligible, evidenceForHead, closedNoop, evaluate, - isTransientAPIError, isCosmeticLabelFlip, replayLastVerdict, BLOCKED_LABEL, + isTransientAPIError, isCosmeticLabelFlip, replayLastVerdict, BLOCKED_LABEL, PR_EVENTS, ProviderUnavailable, ProviderVerdict, PROVIDER_VERDICT_NOTE, FORWARD_MERGE, PROW, DCO_ENUMERATION_SUMMARY_PREFIX, DCO_ENUMERATION_SUMMARY_FALLBACK, DCO_PROVIDER_UNAVAILABLE_TEXT, DCO_PROVIDER_RUNBOOK, diff --git a/.github/scripts/native-queue-policy.test.cjs b/.github/scripts/native-queue-policy.test.cjs index ea58100a1c..eda9162f6c 100644 --- a/.github/scripts/native-queue-policy.test.cjs +++ b/.github/scripts/native-queue-policy.test.cjs @@ -365,6 +365,12 @@ test('PR-target admission consumes policy providers without group APIs', async ( assert.equal(f.state.seen.length, 0); }); +test('open PR on the plain pull_request event is evaluated, not rejected as unsupported', async () => { + const f = fixture('pull_request'); + assert.match(await evaluate(f), /five existing policy providers/); + assert.equal(f.state.queueReads, 0); +}); + test('closed PR on pull_request_target passes as a no-op and skips evidence lookup', async () => { const f = fixture('pull_request_target'); f.state.prs[0].state = 'closed'; @@ -527,6 +533,8 @@ test('isCosmeticLabelFlip is true only for unread labels on label events', () => assert.equal(isCosmeticLabelFlip(ctx('pull_request_target', 'synchronize', 'size/L')), false); assert.equal(isCosmeticLabelFlip(ctx('merge_group', 'checks_requested')), false); assert.equal(isCosmeticLabelFlip(ctx('pull_request_target', 'labeled')), false); + assert.equal(isCosmeticLabelFlip(ctx('pull_request', 'labeled', 'size/L')), true); + assert.equal(isCosmeticLabelFlip(ctx('pull_request', 'labeled', 'hold')), false); }); function replayFixture(priorRuns, labels = [], workflowOverride = {}) { diff --git a/changelog.d/fixed-19100-native-queue-policy-pull-request.md b/changelog.d/fixed-19100-native-queue-policy-pull-request.md new file mode 100644 index 0000000000..af338080b5 --- /dev/null +++ b/changelog.d/fixed-19100-native-queue-policy-pull-request.md @@ -0,0 +1 @@ +- Fixed the `native-queue-policy` check failing with `Unsupported policy event` on PRs whose head carries v5's newer workflow, such as the v5 to v6 top-up (#19100). v5 moved the gate from `pull_request_target` to plain `pull_request` (GitHub blocks `pull_request_target` by default on public repositories from 2026-12-02), but the workflow runs the script from the base branch, so v6's script rejected the event. The v6 script now accepts both events. From 8122b42a8f1389abc49f2cf8c3fb0a72cd534bc6 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 18 Nov 2026 14:53:14 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Align=20native-queue-policy?= =?UTF-8?q?=20tests=20with=20accepted=20pull=5Frequest=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andy Anderson --- .github/scripts/native-queue-policy.test.cjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/scripts/native-queue-policy.test.cjs b/.github/scripts/native-queue-policy.test.cjs index eda9162f6c..d9c4dd29ba 100644 --- a/.github/scripts/native-queue-policy.test.cjs +++ b/.github/scripts/native-queue-policy.test.cjs @@ -428,8 +428,9 @@ test('open PR with moved head still fails closed on pull_request_target', async }); test('untrusted events and workflow provenance are rejected', async () => { - const f = fixture('pull_request'); - await assert.rejects(evaluate(f), /Unsupported/); + for (const eventName of ['push', 'workflow_dispatch', 'issue_comment', 'workflow_run']) { + await assert.rejects(evaluate(fixture(eventName)), /Unsupported/); + } const g = fixture(); g.state.badWorkflow = '.github/workflows/untrusted.yml'; await assert.rejects(evaluate(g), /Unexpected workflow/); @@ -654,7 +655,8 @@ test('replay rejects a same-named success run from another workflow', async () = const run = { id: 7, status: 'completed', conclusion: 'success' }; for (const override of [ { path: '.github/workflows/forged.yml' }, - { event: 'pull_request' }, + { event: 'workflow_dispatch' }, + { event: 'push' }, { head_sha: sha(99) }, { check_suite_id: 1 }, ]) {