Repository navigation
Conversation
akirk
added a commit
to WordPress/wordpress-playground
that referenced
this pull request
Dec 3, 2026
## Motivation for the change, related issues Follow-up to #4826: require both `artifact-id` and `pr` so every exact-artifact request is verified against the PR's latest commit. ```text /plugin-proxy.php?org=WordPress&repo=wordpress-develop&artifact-id=15685328433&pr=16416 ``` Related consumers: WordPress/wordpress-develop#16436, WordPress/gutenberg#87828, and Automattic/woocommerce-payments#12539. ## Implementation details Fetch the exact artifact, its workflow run, and the specified PR directly from GitHub. Require a `pull_request` run whose source repository ID, branch, and SHA match the PR's head. Missing or malformed `pr`, missing source metadata, mismatches, and failed API requests fail closed. `verify_only` enforces the same checks. There is no artifact discovery or fallback. This works for fork runs with an empty `pull_requests` array and avoids unreliable commit-to-PR association. Push and `pull_request_target` runs are rejected. **Compatibility:** exact-ID URLs without `pr` now return HTTP 400. Existing PR/branch discovery routes are unchanged. An artifact-pinned link becomes stale as soon as the PR receives another commit, even before a replacement build completes. Consumer workflows should refresh the comment link after a successful build. Matching a PR's head does not establish that its code is trusted. The README documents the required parameter and stale-link behavior. No quick-start handbook changes are included. ## Testing Instructions (or ideally a Blueprint) - All 25 proxy tests pass, covering matching fork metadata, mismatches, missing metadata, disallowed run events, failed API requests, and missing/malformed PR numbers. Confirmed the missing-PR regression fails against the optional implementation. - PHP syntax checks, focused ESLint, repository formatting, and `git diff --check` pass. Actual GitHub metadata from Core PR #16416 was accepted; changing its PR head was rejected without downloading an archive. - With a local proxy and a valid artifact/PR pair, verify the URL works both normally and with `verify_only`. Remove `pr` or substitute a PR with a mismatched repository, branch, or SHA; expect HTTP 400. AI assistance: OpenAI Codex assisted with implementation, regression coverage, validation, and this description. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Exact GitHub Actions artifact downloads now require a pull request number and are accepted only when the workflow run and its source repository, branch, and commit match the pull request’s current head. * The same validation applies in verification-only mode. Downloads and verification fail when the PR number or required metadata is missing or does not match. Update artifact links after successful builds, as they stop matching when the pull request head changes. * **Documentation** * Added guidance on pull request artifact validation and its limitations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac ticket: https://core.trac.wordpress.org/ticket/66918
I’d like to update the Playground preview links posted on Core pull requests to use exact artifact IDs and PR verification, added in WordPress/wordpress-playground#4826 and WordPress/wordpress-playground#4842.
The existing links resolve the PR through Playground’s plugin proxy, which tries to find the right artifact using the PR’s branch name. This can be ambiguous when contributions from different forks share a branch name. This was also reported at WordPress/wordpress-playground#4614 (comment).
Pinning each link to the specific artifact produced by its build makes the preview’s source explicit and avoids relying on branch-based artifact lookup.
This change:
Existing
core-prandwordpress.html?pr=links continue to work but will no longer be linked in the GitHub comment. Instead, an artifact-pinned link is used. The link in the comment will be updated after each successful build of the latest commit in the PR, including reruns. A copied URL stays pinned to its original artifact but stops working when the PR gets another commit or the artifact expires. A successful build refreshes the link in the comment.The legacy
pr-numberupload is retained because the existing default-branch commenter still consumes it while this PR is under review. The new commenter does not download it.The commenting workflow reads artifact metadata from the exact completed run and checks the PR’s head repository, branch, and SHA before writing. It does not download or execute PR build output. Comment writers for the same source branch are serialized, and comment lookup is paginated so existing preview comments are updated rather than duplicated.
This follows up on https://core.trac.wordpress.org/ticket/59416. A similar change is proposed for Gutenberg in WordPress/gutenberg#87828.
Each exact-artifact URL includes the required
prparameter so the proxy independently verifies the source repository, branch, and latest commit.Sample plugin-proxy URL
Using this PR's latest successful build:
https://playground.wordpress.net/plugin-proxy.php?org=WordPress&repo=wordpress-develop&artifact-id=15706869473&pr=16436
The sample is pinned to this build and becomes stale after another commit is pushed or the artifact expires.
Testing
PR discovery lists open pull requests for the build’s source owner and branch, then validates the head repository ID and SHA. Commit-to-PR association can be empty for fork commits and is not used.
Regression verification: replayed actual GitHub API responses for Core PR #16416 (run 47035587669). The original lookup skipped the PR; the fixed lookup finds it and generates the exact-artifact preview. Comment writes were captured locally, not posted.
Passed locally after rebasing onto current
trunk:git diff --check.Offline Zizmor 1.31.1 reports only findings also present on the unchanged base workflows: the existing privileged triggers and a self-repository reference. There are no new findings.
Manual testing, once the workflow is applied to the default branch and the proxy endpoint is deployed:
preferredVersions.wpusesartifact-idand that the ID belongs to that completed run’swordpress-build-<PR number>artifact.Live end-to-end testing is pending. This change only affects GitHub Actions tooling, so the WordPress runtime test suites were not run.
Use of AI Tools
OpenAI Codex assisted with the implementation, fixture checks, local validation, and PR drafting.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.