Gatsby: [gatsby-source-contentful] TypeError: Cannot read property 'internal' of null

Created on 12 Mar 2018  路  6Comments  路  Source: gatsbyjs/gatsby

Description

Unresolved issue from @0xsven that appeared in #4401 but is not fixed by #4429.

The issue appears to be related to an entity with multi-relation field containing only missing entities. This occurs when a referenced entity is deleted by the user on Contentful.

image

As such, the plugin is returning a entity node that contains a field fieldname_NODE with an empty array that causes [gatsby]/dist/schema/infer-graphql-input-fields.js:239:38 to access a field on an undefined node.

  TypeError: Cannot read property 'internal' of null

  - infer-graphql-input-fields.js:238
    [test-gatsby-contentful]/[gatsby]/dist/schema/infer-graphql-input-fields.js:238:38

  - lodash.js:4917 isBind
    [test-gatsby-contentful]/[lodash]/lodash.js:4917:15

  - lodash.js:3002 baseForOwn
    [test-gatsby-contentful]/[lodash]/lodash.js:3002:24

  - lodash.js:4886 index
    [test-gatsby-contentful]/[lodash]/lodash.js:4886:18

  - lodash.js:9334 Function.forEach
    [test-gatsby-contentful]/[lodash]/lodash.js:9334:14

  - infer-graphql-input-fields.js:225 inferInputObjectStructureFromNodes
    [test-gatsby-contentful]/[gatsby]/dist/schema/infer-graphql-input-fields.js:225:5

  - build-node-types.js:88 _callee$
    [test-gatsby-contentful]/[gatsby]/dist/schema/build-node-types.js:88:36

  - next_tick.js:131 _combinedTickCallback
    internal/process/next_tick.js:131:7

  - From previous event:

  - build-node-types.js:266 _callee2$
    [test-gatsby-contentful]/[gatsby]/dist/schema/build-node-types.js:266:26

  - index.js:38 _callee$
    [test-gatsby-contentful]/[gatsby]/dist/schema/index.js:38:18

Steps to reproduce

I used 0xsven's test project from #4401.

But these steps should reproduce the error in any project:

  1. On Contentful dashboard, edit/create a Content entry for a model that has a field with many relations.
  2. Under that field, click Create entry and link and create a new entry.
  3. In that entry go to Action > Delete and delete the new entry, and accept the popup window.
  4. Run gatsby develop.

Environment

  • Gatsby version: 1.9.231
  • Node.js version: 8.9.1
  • Operating System: Win10

Most helpful comment

All 6 comments

I have this issue. Do you know of any way I can tidy up the broken entities manually in Contentful in the mean time?

I have tried contentful-link-cleaner and it has found 16 broken links and 3 unresolved errors.
Contentful should maybe work on their example project.

After running contentful-link-cleaner my gatsby setup works fine again!

@tremby Having the same issue in my contentful links. When I run the contentful-link-cleaner I get an error. Did you only need your spaceId and accessToken to run it?

@m2mathew: sorry, but I don't remember.

@m2mathew needed spaceId, deliveryToken, managementToken

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jimfilippou picture jimfilippou  路  3Comments

magicly picture magicly  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

theduke picture theduke  路  3Comments

timbrandin picture timbrandin  路  3Comments