Gatsby-source-wordpress-experimental: Inconsistently failing media file downloads

Created on 29 Jul 2020  路  2Comments  路  Source: gatsbyjs/gatsby-source-wordpress-experimental

From @GarryBurch in the WPGraphQL slack:

info  gatsby-source-wordpress  Unrecoverable error occured while fetching media item #26234
Media item link: https://ngu-dev.mrkelly.ninja/sample-page/naegeli-website-video-v1-2/
Edit link: https://ngu-dev.mrkelly.ninja/wp-admin/upload.php?item=26234
File url: https://naegeli-usa.s3.us-east-2.amazonaws.com/wp-content/uploads/2020/07/25071203/Naegeli-Website-Video-v1.webm
 ERROR 
failed to process https://naegeli-usa.s3.us-east-2.amazonaws.com/wp-content/uploads/2020/07/25071203/Naegeli-Website-Video-v1.webm
HTTPError: Response code 400 (Bad Request)

Gatsby info:

 System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 10.21.0 - ~/.nvm/versions/node/v10.21.0/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v10.21.0/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v10.21.0/bin/npm
  Browsers:
    Firefox: 78.0.2
  npmPackages:
    gatsby: ^2.15.34 => 2.24.14
    gatsby-background-image: 0.8.19 => 0.8.19
    gatsby-image: ^2.4.13 => 2.4.14
    gatsby-plugin-antd: ^2.2.0 => 2.2.0
    gatsby-plugin-lodash: ^3.3.10 => 3.3.10
    gatsby-plugin-manifest: ^2.4.21 => 2.4.21
    gatsby-plugin-offline: ^3.2.21 => 3.2.21
    gatsby-plugin-prefetch-google-fonts: ^1.4.3 => 1.4.3
    gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10
    gatsby-plugin-react-svg: ^3.0.0 => 3.0.0
    gatsby-plugin-sharp: ^2.6.22 => 2.6.23
    gatsby-plugin-sitemap: ^2.4.11 => 2.4.11
    gatsby-plugin-styled-components: ^3.3.10 => 3.3.10
    gatsby-plugin-typescript: ^2.4.16 => 2.4.16
    gatsby-source-filesystem: ^2.3.23 => 2.3.23
    gatsby-source-wordpress-experimental: ^1.0.7 => 1.2.1
    gatsby-transformer-sharp: ^2.5.11 => 2.5.11
  npmGlobalPackages:
    gatsby-cli: 2.12.66

This is for another one of our clients - just started this morning
WP Gatsby v0.4.14
WP GraphQL v0.10.3
Each build attempt will have a different asset as the source of the bad request - As seen with provided link the urls are good - been working for the past 2 months as we have been building it out....

bug

Most helpful comment

So the issue here is that this WP instance is protected with htaccess auth. The source plugin has a built in option for sending htaccess headers but the issue is that these media items are hosted on s3 and to s3 sending these htaccess headers resulted in a "malformed auth headers" error. The solution was to first check if the media item url has the same hostname as the WP instance before adding the htaccess headers.

Fix published in [email protected]

All 2 comments

So the issue here is that this WP instance is protected with htaccess auth. The source plugin has a built in option for sending htaccess headers but the issue is that these media items are hosted on s3 and to s3 sending these htaccess headers resulted in a "malformed auth headers" error. The solution was to first check if the media item url has the same hostname as the WP instance before adding the htaccess headers.

Fix published in [email protected]

Was this page helpful?
0 / 5 - 0 ratings