Gatsby: Plugin gatsby-source-drupal returned an error

Created on 6 Aug 2018  路  10Comments  路  Source: gatsbyjs/gatsby

Description

Steps to reproduce

Installed Drupal8 on localhost
Installed JSON api module and gave anonymous users permission
Installed gatsby drupal module
Entered baseurl and apibase correctly
my http://localhost/jsonapi is returning valid json and I can curl it perfectly

Expected result

Should run without errors

Actual result

Throws 405 error:
error Plugin gatsby-source-drupal returned an error
Error: Request failed with status code 405

Environment

System:
OS: macOS High Sierra 10.13.3
CPU: x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.9.4 - /usr/local/bin/node
npm: 6.3.0 - /usr/local/bin/npm
Browsers:
Chrome: 68.0.3440.84
Safari: 11.0.3
npmPackages:
gatsby: ^1.9.277 => 1.9.277
gatsby-link: ^1.6.46 => 1.6.46
gatsby-plugin-react-helmet: ^2.0.11 => 2.0.11
gatsby-source-drupal: ^2.0.41 => 2.0.41
npmGlobalPackages:
gatsby-cli: 1.1.58

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

maintenance question or discussion

Most helpful comment

@nicklewisatx my guess is that that endpoint allows access with method types other than GET.

All 10 comments

@belgianwolfie can you update your packages to the latest version?

@Chuloo getting identical errors. Gatsby and drupal site were both created in the last hour. Can also confirm my test site is available: http://nicklewisatx8jeduqqrqmb.devcloud.acquia-sites.com/jsonapi
My gatsby-config.js is as bare bones as it gets.
module.exports = {
siteMetadata: {
title: 'Gatsby Default Starter',
},
plugins: [
'gatsby-plugin-react-helmet',
{
resolve: gatsby-source-drupal,
options: {
baseUrl: http://nicklewisatx8jeduqqrqmb.devcloud.acquia-sites.com/,
apiBase: jsonapi, // optional, defaults to jsonapi
},
}
],
}

@Chuloo @belgianwolfie this is a problem with the jsonapi module.
The following uri is what returns 405 breaking the whole thing:
/jsonapi/contact_message/personal

You can work around it by uninstalling the contact form.

Linking jsonapi issue for reference: https://www.drupal.org/project/jsonapi/issues/2991231

Provided explanation at https://www.drupal.org/project/jsonapi/issues/2991231#comment-12721346 :)

馃憤 sounds like we should just ignore 405 errors then. Anyone interested in working on a PR?

uninstalling the contact module did the trick for me. Thanks so much all that contributed.

@KyleAMathews Took a crack at a PR but being relatively new to gatsby and node, I think it may be over my head. Here's what I learned.

  1. The plugin uses the axios library to make requests. The axios library does allow you to extend error handling. Axios throws an error on 400s. Not everyone agrees this is a good idea: https://github.com/axios/axios/issues/41
  2. I tried numerous methods ranging from cancelling requests, to altering the error handlers. While I can whitelist 405 errors to pass, the request still fails because code is assuming a object.data property later in the process. Altering that code to check for this exception seemed... unseemly...

@wimleers not to be argumentative, but why include the contact message endpoint at /jsonapi at all if it's assumed to be broken without contact_storage module enabled? Also briefly looked into a pr for that, but haven't had time yet to figure out how those links get added to the endpoint root. (a simple module enable check seems reasonable, no?)

@nicklewisatx my guess is that that endpoint allows access with method types other than GET.

@nicklewisatx

@wimleers not to be argumentative, but why include the contact message endpoint at /jsonapi at all if it's assumed to be broken without contact_storage module enabled?

@tmccombs's guess is correct:

@nicklewisatx my guess is that that endpoint allows access with method types other than GET.

This was simply a wrong assumption in this API client; the #7318 PR fixed it! 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

signalwerk picture signalwerk  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

jimfilippou picture jimfilippou  路  3Comments