gatsby: `construct-error.js` - child "error" fails because ["error" must be an object]

Description

Introducing a query error on MarkdownRemarkFrontmatter seems to throw error with construct-error.js due to some error in validating an error type using the joi library. The error message thrown is:

child "error" fails because ["error" must be an object]

Original Build Error Log This behavior will be removed in the next major release of gatsby-plugin-feed. For more info, check out: https://gatsby.app/adding-rss-feed success onPreBootstrap - 0.044 s success source and transform nodes - 0.236 s success building schema - 0.581 s child "error" fails because ["error" must be an object] Failed to validate error { ValidationError: child "error" fails because ["error" must be an object] at Object.exports.process (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/node_modules/gatsby-cli/node_modules/@hapi/joi/lib/errors.js:203:19) at internals.Object._validateWithOptions (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/node_modules/gatsby-cli/node_modules/@hapi/joi/lib/types/any/index.js:764:31) at module.exports.internals.Any.root.validate (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/node_modules/gatsby-cli/node_modules/@hapi/joi/lib/index.js:145:23) at constructError (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/node_modules/gatsby-cli/lib/structured-errors/construct-error.js:28:29) at Object.error (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/node_modules/gatsby-cli/lib/reporter/index.js:100:29) at Object.panicOnBuild (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/node_modules/gatsby-cli/lib/reporter/index.js:66:24) at Promise.catch.err (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/dist/utils/api-runner-node.js:359:16) at tryCatcher (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/promise.js:690:18) at _drainQueueStep (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/async.js:138:12) at _drainQueue (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/async.js:131:9) at Async._drainQueues (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/async.js:147:5) at Immediate.Async.drainQueues (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/async.js:17:14) isJoi: true, name: 'ValidationError', details: [ { message: '"error" must be an object', path: [Array], type: 'object.base', context: [Object] } ], _object: { error: [ [Object] ], context: { sourceMessage: 'gatsby-node.js returned an error undefined' }, text: 'gatsby-node.js returned an error undefined', level: 'ERROR', stack: [], docsUrl: 'https://gatsby.dev/issue-how-to' }, annotate: [Function] } ⠋ createPages npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! unicorn-utterances-site@0.1.0 develop: `gatsby develop` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the unicorn-utterances-site@0.1.0 develop script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Adding a console.error to the contruct-error.js file before doing the joi validation yeilds me a much better error message:

GraphQLError: Cannot query field "attached" on type "MarkdownRemarkFrontmatter".

The "Better" error { error: [ { GraphQLError: Cannot query field "attached" on type "MarkdownRemarkFrontmatter". at Object.Field (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31) at Object.enter (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/language/visitor.js:324:29) at Object.enter (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/language/visitor.js:375:25) at visit (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/language/visitor.js:242:26) at validate (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/validation/validate.js:54:22) at graphqlImpl (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/graphql.js:99:50) at /Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/graphql.js:28:59 at new Promise (<anonymous>) at graphql (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/graphql/graphql.js:26:10) at graphqlRunner (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/dist/bootstrap/index.js:353:12) at Object.exports.createPages (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/gatsby-node.js:10:10) at runAPI (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/dist/utils/api-runner-node.js:230:37) at resolve (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/gatsby/dist/utils/api-runner-node.js:352:15) at Promise._execute (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/debuggability.js:313:9) at Promise._resolveFromExecutor (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/promise.js:483:18) at new Promise (/Users/ccrutchley/git/Etc/UnicornUtter/blog-dev/node_modules/bluebird/js/release/promise.js:79:10) message: 'Cannot query field "attached" on type "MarkdownRemarkFrontmatter".', locations: [Array] } ], context: { sourceMessage: 'gatsby-node.js returned an error undefined' }, text: 'gatsby-node.js returned an error undefined', level: 'ERROR', stack: [], docsUrl: 'https://gatsby.dev/issue-how-to' }

Steps to reproduce

It’s like 4AM, and I’m like falling asleep. Sincere apologies for not leaving a reproducible repo as a result 😕 . If this is unable to be duplicated, whenever I wake up I can give it my best crack at one.

Environment

Run gatsby info --clipboard in your project directory and paste the output here.

My system info ✘ 💅  ~/git/Etc/UnicornUtter/blog-dev   master ●✚  ↳ npx gatsby info --clipboard

System: OS: macOS High Sierra 10.13.6 CPU: (4) x64 Intel® Core™ i5-7360U CPU @ 2.30GHz Shell: 5.3 - /bin/zsh Binaries: Node: 8.16.0 - ~/.nvm/versions/node/v8.16.0/bin/node Yarn: 1.17.0 - /usr/local/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v8.16.0/bin/npm Languages: Python: 2.7.16 - /usr/local/bin/python Browsers: Chrome: 75.0.3770.100 Safari: 12.1.1 npmPackages: gatsby: ^2.11.3 => 2.11.3 gatsby-image: ^2.2.3 => 2.2.3 gatsby-plugin-feed: ^2.3.1 => 2.3.1 gatsby-plugin-google-analytics: ^2.1.1 => 2.1.1 gatsby-plugin-lunr: ^1.5.1 => 1.5.1 gatsby-plugin-manifest: ^2.2.0 => 2.2.0 gatsby-plugin-offline: ^2.2.0 => 2.2.0 gatsby-plugin-prefetch-google-fonts: ^1.4.2 => 1.4.2 gatsby-plugin-react-helmet: ^3.1.0 => 3.1.0 gatsby-plugin-react-svg: ^2.1.1 => 2.1.1 gatsby-plugin-sass: ^2.1.0 => 2.1.0 gatsby-plugin-sharp: ^2.2.1 => 2.2.1 gatsby-plugin-transition-link: ^1.12.4 => 1.12.4 gatsby-remark-autolink-headers: ^2.1.0 => 2.1.0 gatsby-remark-copy-linked-files: ^2.1.0 => 2.1.0 gatsby-remark-images: ^3.1.2 => 3.1.2 gatsby-remark-prismjs: ^3.3.0 => 3.3.0 gatsby-remark-responsive-iframe: ^2.2.1 => 2.2.1 gatsby-source-filesystem: ^2.1.1 => 2.1.1 gatsby-transformer-json: ^2.2.0 => 2.2.0 gatsby-transformer-remark: ^2.5.0 => 2.5.0 gatsby-transformer-sharp: ^2.2.0 => 2.2.0

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 12
  • Comments: 27 (13 by maintainers)

Most upvoted comments

Got this error after deleting the gatsby icon from images folder. Omg it took a long time to fix. finally found the issue by logging the error in node_modules\gatsby\node_modules\gatsby-cli\lib\reporter\index.js above line 100. I mean Ok Ok jeez fine, I wont delete your icon logo, haha.

edit: Gatasby-plugin-manifest complained cause the icon was still referenced in the gatsby config file.

For anyone else that comes in looking for a solution, for mine it was import capitalization typos. Look at the files in the error and check the imports. They didn’t break locally with develop or build, but failed on deploy in Netlify.

I found it from this https://stackoverflow.com/questions/56926593/gatsby-failed-deployment-to-netlify-failed-to-validate-error-validationerror

oh I missed that 🙈 thanks for creating another one!

@pieh I am having the very same error. Running the latest gatsby 2.13.3:

Failed to validate error { ValidationError: child "error" fails because ["error" must be an
object]
    at Object.exports.process
(/Users/tomi/Github/apps/toryjs/node_modules/@hapi/joi/lib/errors.js:202:19)
    at internals.Object._validateWithOptions
(/Users/tomi/Github/apps/toryjs/node_modules/@hapi/joi/lib/types/any/index.js:764:31)
    at module.exports.internals.Any.root.validate
(/Users/tomi/Github/apps/toryjs/node_modules/@hapi/joi/lib/index.js:145:23)
    at constructError (/Users/tomi/Github/apps/toryjs/node_modules/gatsby-cli/lib/structured-erro
rs/construct-error.js:28:29)
    at Object.error
(/Users/tomi/Github/apps/toryjs/node_modules/gatsby-cli/lib/reporter/index.js:100:29)
    at Object.panic
(/Users/tomi/Github/apps/toryjs/node_modules/gatsby-cli/lib/reporter/index.js:58:24)
    at reportFailure
(/Users/tomi/Github/apps/toryjs/node_modules/gatsby/dist/commands/build.js:47:10)
    at buildProductionBundle.catch.err
(/Users/tomi/Github/apps/toryjs/node_modules/gatsby/dist/commands/build.js:102:5)
  isJoi: true,
  name: 'ValidationError',
  details:
   [ { message: '"error" must be an object',
       path: [Array],
       type: 'object.base',
       context: [Object] } ],
  _object:
⠹ Building production JavaScript and CSS bundles
error Command failed with exit code 1.