Skip to content

Gutenberg PR Preview: Broken check for the build artifact availability #1568

Closed

Description

@WunderBart

The endpoint for checking the zipped build availability returns a different payload depending on the artifact availability, but it's always a 200:

Request Artifact unavailable Artifact available
Code 200 200
Payload JSON: { "error": "Request failed" } zip file

The code that validates the artifact availability checks only whether it's a 200 or not, meaning it always passes that check. The consequence is that a wrong error is thrown, which can be misleading:

JavaScript Error: Error when executing the blueprint step #2 ({"step":"writeFile","path":"/wordpress/pr/pr.zip","data":{"resource":"url","url":"/plugin-proxy.php?org=WordPress&repo=gutenberg&workflow=Build%20Gutenberg%20Plugin%20Zip&artifact=gutenberg-plugin&pr=59242","caption":"Downloading Gutenberg PR 59242"},"progress":{"weight":2,"caption":"Applying Gutenberg PR 59242"}}) : Could not download "/plugin-proxy.php?org=WordPress&repo=gutenberg&workflow=Build%20Gutenberg%20Plugin%20Zip&artifact=gutenberg-plugin&pr=59242".
Check if the URL is correct and the server is reachable.
If it is reachable, the server might be blocking the request.

The correct error thrown should be:

The PR 12345 does not exist or GitHub CI did not finish building it yet.

Activity

  1. moved this from Inbox to Needs Triage/Our Reply in Playground Boardon Jul 5, 2024
  2. moved this from Needs Triage/Our Reply to Up next in Playground Boardon Jul 5, 2024
  3. self-assigned this
    on Jul 22, 2024
  4. moved this from Up next to In progress in Playground Boardon Jul 22, 2024
  5. bgrgicak commented on Jul 22, 2024

    @bgrgicak
    Collaborator

    @brandonpayton I could use your help with this one because it looks like a server issue.

    Production

    I get a 200 and an empty plugin-proxy.php is downloaded.

    https://playground.wordpress.net/plugin-proxy.php?org=WordPress&repo=gutenberg&workflow=Build%20Gutenberg%20Plugin%20Zip&artifact=gutenberg-plugin&pr=59242&verify_only=true

    Locally

    Start a server:

    cd packages/playground/website/public/
    php -S localhost:4321 -d .
    

    I get a 400 error as expected.

    http://localhost:4321/plugin-proxy.php?org=WordPress&repo=gutenberg&workflow=Build%20Gutenberg%20Plugin%20Zip&artifact=gutenberg-plugin&pr=59242&verify_only=true

  6. adamziel commented on Oct 16, 2024

    @adamziel
    Collaborator

    @bgrgicak are you setting GITHUB_TOKEN locally?

  7. adamziel commented on Oct 16, 2024

    @adamziel
    Collaborator

    The problem here is that the /plugin-proxy.php?verify_only=yes request short-circuits with HTTP 200 when it finds an artifact:

    if (array_key_exists('verify_only', $_GET)) {

    Whereas the /plugin-proxy.php request tries to fetch that artifact and, in doing so, may fail if the actual file is not available.

    This diff seems to solve it:

    diff --git a/packages/playground/website/public/plugin-proxy.php b/packages/playground/website/public/plugin-proxy.php
    index 59f9522afb..b1a55216a4 100644
    --- a/packages/playground/website/public/plugin-proxy.php
    +++ b/packages/playground/website/public/plugin-proxy.php
    @@ -87,16 +87,6 @@ class PluginDownloader
                     continue;
                 }
     
    -            /*
    -             * Short-circuit with HTTP 200 OK when we only want to
    -             * verify whether the CI artifact seems to exist but we
    -             * don't want to download it yet.
    -             */
    -            if (array_key_exists('verify_only', $_GET)) {
    -                header('HTTP/1.1 200 OK');
    -                return;
    -            }
    -
                 $allowed_headers = array(
                     'content-length',
                     'content-disposition',
    @@ -112,6 +102,16 @@ class PluginDownloader
                 ob_end_flush();
                 flush();
     
    +            /*
    +             * Short-circuit with HTTP 200 OK when we only want to
    +             * verify whether the CI artifact seems to exist but we
    +             * don't want to download it yet.
    +             */
    +            if (array_key_exists('verify_only', $_GET)) {
    +                header('HTTP/1.1 200 OK');
    +                return;
    +            }
    +
                 // The API endpoint returns the actual artifact URL as a 302 Location header.
                 foreach ($artifact_res['headers'] as $header_line) {
                     $header_name = strtolower(substr($header_line, 0, strpos($header_line, ':')));

    Any takes to make it into a PR?

  8. fellyph commented on Sep 23, 2026

    @fellyph
    Collaborator

    This issue is fixed in PR #1636, so I would close this item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions