gatsbyjs/gatsby-source-wordpress-experimental

Build failing with Error since we upgraded WpgraphQl, WpGatsby and Gatsby-wordpress-experimental

Closed this issue · 15 comments

We are getting a weird error since we upgraded WpgraphQl, WpGatsby and Gatsby-woordpress-experimental.

Error :

Failed to validate error Error [ValidationError]: "config" is not allowed. "request" is not allowed. "response" is not allowed. "isAxiosError" is not allowed. "toJSON" is not allowed
    at Object.exports.process (D:\Gatsby\Obs-Git\OBSBeta\node_modules\@hapi\joi\lib\errors.js:202:19)
    at internals.Object._validateWithOptions (D:\Gatsby\Obs-Git\OBSBeta\node_modules\@hapi\joi\lib\types\any\index.js:763:31)
    at internals.Object.validate (D:\Gatsby\Obs-Git\OBSBeta\node_modules\@hapi\joi\lib\types\any\index.js:797:21)
    at constructError (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby\node_modules\gatsby-cli\lib\structured-errors\construct-error.js:52:32)
    at Reporter.error (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby\node_modules\gatsby-cli\lib\reporter\reporter.js:135:59)
    at Object.error (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby\src\utils\api-runner-node.js:190:16)
    at handleFetchErrors (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby-source-wordpress-experimental\src\utils\fetch-graphql.js:236:14)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at fetchGraphql (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby-source-wordpress-experimental\src\utils\fetch-graphql.js:539:5)
    at paginatedWpNodeFetch (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby-source-wordpress-experimental\src\steps\source-nodes\fetch-nodes\fetch-nodes-paginated.js:59:20)
    at fetchWPGQLContentNodes (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby-source-wordpress-experimental\src\steps\source-nodes\fetch-nodes\fetch-nodes.js:44:26)
    at D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby-source-wordpress-experimental\src\steps\source-nodes\fetch-nodes\fetch-nodes.js:149:30
    at D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby-source-wordpress-experimental\src\steps\source-nodes\fetch-nodes\fetch-nodes.js:139:9
    at async Promise.all (index 6)
    at runFnForEachNodeQuery (D:\Gatsby\Obs-Git\OBSBeta\node_modules\gatsby-source-wordpress-experimental\src\steps\source-nodes\fetch-nodes\fetch-nodes.js:127:5) {
  isJoi: true,
  name: 'ValidationError',
  details: [
    {
      message: '"config" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"request" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"response" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"isAxiosError" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"toJSON" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    }
  ],
  _object: {
    context: {},
    config: {
      url: 'https://backend.observalgerie.com/graphql',
      method: 'post',
      data: '{"query":" query NODE_LIST_QUERY($first:Int!,$after:String,){villesEtLieux(first:$first,after:$after,){nodes{ancestors(first:100){nodes{id}}wpChildren:children(first:100){nodes{id}}contentNodes(first:100){nodes{id __typename}}count databaseId description id link name wpParent:parent{node{id}}parentDatabaseId parentId posts(first:100){nodes{id}}seo{breadcrumbs{text url}canonical cornerstone focuskw metaDesc metaKeywords metaRobotsNofollow metaRobotsNoindex opengraphAuthor opengraphDescription opengraphImage{__typename id}opengraphModifiedTime opengraphPublishedTime opengraphPublisher opengraphSiteName opengraphTitle opengraphType opengraphUrl title twitterDescription twitterImage{__typename id}twitterTitle}slug taxonomy{node{id}}termGroupId termTaxonomyId uri __typename}pageInfo{hasNextPage endCursor}}}","variables":{"first":100,"url":"https://backend.observalgerie.com/graphql","after":null}}',
      headers: [Object],
      auth: [Object],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 30000,
      adapter: [Function: httpAdapter],
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      validateStatus: [Function: validateStatus]
    },
    code: 'ECONNABORTED',
    request: Writable {
      _writableState: [WritableState],
      writable: true,
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _options: [Object],
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 904,
      _requestBodyBuffers: [Array],
      _onNativeResponse: [Function],
      _currentRequest: [ClientRequest],
      _currentUrl: 'backend.observalgerie.com/graphql',
      [Symbol(kCapture)]: false
    },
    response: undefined,
    isAxiosError: true,
    toJSON: [Function],
    pluginName: 'gatsby-source-wordpress-experimental',
    text: 'There was an error',
    level: 'ERROR',
    stack: [],
    docsUrl: 'https://gatsby.dev/issue-how-to'
  },
  annotate: [Function]
}

Package.json

{
  "name": "obs-beta",
  "private": true,
  "description": "An Obs Beta version with Gatsby & WordPress",
  "version": "0.1.0",
  "author": "Khaled Belkouche <Khaled.belkouche@gmail.com>",
  "dependencies": {
    "@apollo/client": "^3.2.7",
    "@hot-loader/react-dom": "^17.0.0",
    "@material-ui/core": "^4.11.0",
    "@material-ui/icons": "^4.9.1",
    "@sideway/address": "^4.1.0",
    "babel-plugin-styled-components": "^1.11.1",
    "core-js": "^3.7.0",
    "gatsby": "^2.26.1",
    "gatsby-image": "^2.5.0",
    "gatsby-plugin-manifest": "^2.6.1",
    "gatsby-plugin-material-ui": "^2.1.10",
    "gatsby-plugin-offline": "^3.4.0",
    "gatsby-plugin-react-helmet": "^3.4.0",
    "gatsby-plugin-sharp": "^2.8.0",
    "gatsby-plugin-styled-components": "^3.4.0",
    "gatsby-source-filesystem": "^2.5.0",
    "gatsby-source-graphql": "^2.8.0",
    "gatsby-source-wordpress": "^3.5.0",
    "gatsby-source-wordpress-experimental": "^3.0.1",
    "gatsby-transformer-sharp": "^2.6.0",
    "graphql-tag": "^2.11.0",
    "html-react-parser": "^0.14.1",
    "isomorphic-fetch": "^3.0.0",
    "joi": "^17.3.0",
    "prop-types": "^15.7.2",
    "react": "^17.0.1",
    "react-helmet": "^6.1.0",
    "react-waypoint": "^9.0.3",
    "styled-components": "^5.2.1"
  },
  "devDependencies": {
    "prettier": "2.1.2"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "0BSD",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/kabylebot/obsbeta"
  },
  "bugs": {
    "url": "https://github.com/kabylebot/obsbeta/issues"
  }
}

Config.js:

module.exports = {
  plugins: [
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    {
      resolve: `gatsby-plugin-material-ui`,
      options: {
        stylesProvider: {
          injectFirst: true,
        },
      },
    },
    `gatsby-plugin-styled-components`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `OBS Algérie Version Beta`,
        short_name: `OBS`,
        start_url: `/`,
        background_color: `#00de85`,
        theme_color: `#33cc33`,
        display: `minimal-ui`,
        icon: `src/images/Logo-OBS.png`, // This path is relative to the root of the site.
      },
    },
    {
      resolve: `gatsby-source-wordpress-experimental`,
      options: {
        fieldName: "wpcontent",
        url:
          // allows a fallback url if WPGRAPHQL_URL is not set in the env, this may be a local or remote WP instance.
          process.env.WPGRAPHQL_URL ||
          `https://backend.observalgerie.com/graphql`,
        schema: {
          //Prefixes all WP Types with "Wp" so "Post and allPost" become "WpPost and allWpPost".
          typePrefix: `Wp`,
        },
        develop: {
          //caches media files outside of Gatsby's default cache an thus allows them to persist through a cache reset.
          hardCacheMediaFiles: false,
        },
        type: {
          Post: {
            limit:
              process.env.NODE_ENV === `development`
                ? // Lets just pull 50 posts in development to make it easy on ourselves (aka. faster).
                  100
                : // and we don't actually need more than 5000 in production for this particular site
                  10000,
          },
        },
        html: {
          useGatsbyImage: true,
          fallbackImageMaxWidth: 800,
          withWebp: true,
        },
      },
    },
  ],
}

In Wordpress Backend we are using : Wpgraphql, WpGatsby, Yoast SEO, Pods – Custom Content Types and Fields, Cloudinary

I'm getting the same error intermittently.

Failed to validate error Error [ValidationError]: "config" is not allowed. "request" is not allowed. "response" is not allowed. "isAxiosError" is not allowed. "toJSON" is not allowed
    at Object.exports.process (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/@hapi/joi/lib/errors.js:202:19)
    at internals.Object._validateWithOptions (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/@hapi/joi/lib/types/any/index.js:763:31)
    at internals.Object.validate (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/@hapi/joi/lib/types/any/index.js:797:21)
    at constructError (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-cli/lib/structured-errors/construct-error.js:52:32)
    at Reporter.error (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-cli/lib/reporter/reporter.js:135:59)
    at Object.error (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby/src/utils/api-runner-node.js:190:16)
    at handleFetchErrors (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-source-wordpress-experimental/src/utils/fetch-graphql.js:236:14)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at fetchGraphql (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-source-wordpress-experimental/src/utils/fetch-graphql.js:539:5)
    at paginatedWpNodeFetch (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-source-wordpress-experimental/src/steps/source-nodes/fetch-nodes/fetch-nodes-paginated.js:59:20)
    at fetchWPGQLContentNodes (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-source-wordpress-experimental/src/steps/source-nodes/fetch-nodes/fetch-nodes.js:44:26)
    at /mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-source-wordpress-experimental/src/steps/source-nodes/fetch-nodes/fetch-nodes.js:149:30
    at /mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-source-wordpress-experimental/src/steps/source-nodes/fetch-nodes/fetch-nodes.js:139:9
    at async Promise.all (index 6)
    at runFnForEachNodeQuery (/mnt/c/Users/Alex/code/moonmeister/moonmeister.net/node_modules/gatsby-source-wordpress-experimental/src/steps/source-nodes/fetch-nodes/fetch-nodes.js:127:5) {
  isJoi: true,
  details: [
    {
      message: '"config" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"request" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"response" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"isAxiosError" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    },
    {
      message: '"toJSON" is not allowed',
      path: [Array],
      type: 'object.allowUnknown',
      context: [Object]
    }
  ],
  _object: {
    context: {},
    config: {
      url: 'https://cms.moonmeister.net/graphql',
      method: 'post',
      data: '{"query":" query NODE_LIST_QUERY($first:Int!,$after:String,){menus(first:$first,after:$after,){nodes{count databaseId id locations menuItems(first:100){nodes{id}}name slug __typename}pageInfo{hasNextPage endCursor}}}","variables":{"first":100,"url":"https://cms.moonmeister.net/graphql","after":null}}',
      headers: [Object],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 30000,
      adapter: [Function: httpAdapter],
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      validateStatus: [Function: validateStatus]
    },
    code: 'ECONNABORTED',
    request: Writable {
      _writableState: [WritableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _options: [Object],
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 301,
      _requestBodyBuffers: [Array],
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: [ClientRequest],
      _currentUrl: 'https://cms.moonmeister.net/graphql',
      [Symbol(kCapture)]: false
    },
    response: undefined,
    isAxiosError: true,
    toJSON: [Function (anonymous)],
    pluginName: 'gatsby-source-wordpress-experimental',
    text: 'There was an error',
    level: 'ERROR',
    stack: [],
    docsUrl: 'https://gatsby.dev/issue-how-to'
  },
  annotate: [Function (anonymous)]
}```

This is really odd 🤔 we recently added support for the pluginOptionsSchema node API that was recently added to Gatsby but that shouldn't be affecting axios.. Are either of you able to share a reproduction /graphql url and repo so I can reproduce and debug? I haven't run into this myself, weirdly.

Thanks!

Tyler I believe you can still login to my WordPress site : https://cms.moonmeister.net/wp-admin

Code is on my https://github.com/moonmeister/moonmeister.net

Ah, of course. Thanks Alex!

Can you run gatsby info? I wonder if this is somehow related to being on a version of gatsby that doesn't have the pluginOptionsSchema API. That'd be weird but it'd be good to rule it out.

No matter how many times I run a build of your site I don't get that error 😱 gatsby info is definitely needed here so I can make sure my setup is as close to yours as possible.


  System:
    OS: Linux 4.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
    Yarn: 1.22.10 - /mnt/c/Users/Alex/AppData/Roaming/npm/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
  npmPackages:
    gatsby: ^2.26.1 => 2.26.1
    gatsby-image: ^2.5.0 => 2.5.0
    gatsby-plugin-feed: ^2.7.0 => 2.7.0
    gatsby-plugin-goatcounter: ^0.4.0 => 0.4.0
    gatsby-plugin-linaria: ^2.2.0 => 2.2.0
    gatsby-plugin-manifest: ^2.6.1 => 2.6.0-next.0
    gatsby-plugin-netlify: ^2.5.0 => 2.5.0
    gatsby-plugin-offline: ^3.4.0 => 3.4.0
    gatsby-plugin-postcss: ^3.1.0 => 3.1.0
    gatsby-plugin-preact: ^4.1.0 => 4.1.0
    gatsby-plugin-react-helmet: ^3.4.0 => 3.4.0
    gatsby-plugin-readingtime: ^1.0.1 => 1.0.1
    gatsby-plugin-robots-txt: ^1.5.3 => 1.5.3
    gatsby-plugin-sharp: ^2.8.0 => 2.8.0
    gatsby-plugin-sitemap: ^2.6.0 => 2.6.0
    gatsby-plugin-webpack-bundle-analyzer: ^1.0.5 => 1.0.5
    gatsby-plugin-webpack-size: ^1.0.0 => 1.0.0
    gatsby-source-filesystem: ^2.5.0 => 2.5.0
    gatsby-source-wordpress-experimental: ^3.0.1 => 3.0.1
    gatsby-transformer-sharp: ^2.6.0 => 2.6.0

Thanks Alex! And I was able to reproduce with your /graphql url @KabyleBOT . Investigating now

I've only gotten this error twice and run build a dozen or more times FYI. but also notice code: ECONNABORTED I think this is some kind of tcp issue causes the error then Joi tries to validate it somehow...

I think it's because I'm passing an error object into reporter.error() which it seems now has Joi validation and doesn't allow that anymore 🤔 I'm trying to just pass the error message there instead now which I assume will fix it.

Yep, this is due to timeouts. A more detailed error is printed out on the next line but because Joi was throwing a validation error for reporter.error() it never got to that point.

Makes sense, I'm on a slow connection.

This is fixed in gatsby-source-wordpress-experimental@3.0.3! Thanks so much for reporting this and for helping me reproduce it!

Thank you very much. I will try that. And let you know :)

Its Working 👍 Thanks