Gatsby-source-plugin threw an error while running the createSchemaCustomization lifecycle

So I've recently updated a few of my projects to V5 of the gatsby-source-prismic. Most work perfectly but 2 prismic repos are having problems.

"gatsby-source-prismic" threw an error while running the createSchemaCustomization lifecycle:
Cannot convert undefined or null to object
TypeError: Cannot convert undefined or null to object

Both of these Prismic repos are fairly old. 1 of them seems to work if I stop using the customTypesApiToken and instead manually write out the schemas.

The other throws the error but continues to run locally if I remove the gatsby-plugin-prismic-previews

Initially i though it was due to API permission on the repo, but I've removed all permissions and nothing seems to resolve it.

To test a theory I took a branch of the project. running on Gatsby V3 and Prismic V4 using the customTypesApiToken and everything run perfectly.

I upgraded all the packages to Gatsby v4 and this error has started to appear.

I'm now going to keep all gatsby plugins at v4 but drop the prismic plugins down from v5.

I've updated everything apart from the Prismic plugins...

npm outdated
Package                         Current  Wanted  Latest  Location
gatsby-plugin-prismic-previews    4.2.0   4.2.0   5.0.0  {repo name}
gatsby-source-prismic             4.2.0   4.2.0   5.0.0  {repo name}

and everything works perfectly, so its definitely a problem introduced int h V5 update.

Hello
Currently, I am using 5.0.0 version of Prismic plugins, it shows this error.

Do you mean can't we use this version?

This example site uses 5.0.0 version.

Could you explain more detail about this?

Hi. @andyrockport8 I think this is a problem with the V5 plugin. For some of my repos it works perfectly, for other repos (generally older repos) I keep getting this error.

What works for me at the moment is upgrading all Gatsby plugins to Gatsby V4 but keep the Prismic plugin on 4 rather than upgrading to 5.

Everything will then work properly.

Hi @thejuniperstudio and @andyrockport8,

Thanks for the info. Are you able to share the full error, including the stack trace below the "TypeError: Cannot convert undefined…" message?

Are you also able to send me the names of the Prismic repositories? The error might be specific to the Custom Types being used.

You can share that info here or you can send me a private message. I'll try to figure out the cause and publish a fix as soon as possible. Thank you!

The full stack trace...

 ERROR #11321  PLUGIN

"gatsby-source-prismic" threw an error while running the createSchemaCustomization lifecycle:

Cannot convert undefined or null to object



  TypeError: Cannot convert undefined or null to object

  - Function.entries

  - typePaths.ts:62 fieldToTypePaths
    [apex-auctions]/[gatsby-source-prismic]/src/runtime/typePaths.ts:62:25

  - typePaths.ts:42
    [apex-auctions]/[gatsby-source-prismic]/src/runtime/typePaths.ts:42:6

  - Array.flatMap

  - typePaths.ts:41 fieldToTypePaths
    [apex-auctions]/[gatsby-source-prismic]/src/runtime/typePaths.ts:41:6

  - typePaths.ts:115
    [apex-auctions]/[gatsby-source-prismic]/src/runtime/typePaths.ts:115:4

  - Array.flatMap

  - typePaths.ts:114 customTypeModelToTypePaths
    [apex-auctions]/[gatsby-source-prismic]/src/runtime/typePaths.ts:114:44

  - runtime.ts:110
    [apex-auctions]/[gatsby-source-prismic]/src/runtime/runtime.ts:110:5

  - Array.flatMap

  - runtime.ts:109 Runtime.registerCustomTypeModels
    [apex-auctions]/[gatsby-source-prismic]/src/runtime/runtime.ts:109:11

  - create-schema-customization.ts:105
    [apex-auctions]/[gatsby-source-prismic]/src/create-schema-customization.ts:105:18

  - Chain.js:5
    [apex-auctions]/[fp-ts]/lib/Chain.js:5:103

  - EitherT.js:52
    [apex-auctions]/[fp-ts]/lib/EitherT.js:52:116

  - ReaderT.js:18
    [apex-auctions]/[fp-ts]/lib/ReaderT.js:18:116

  - Task.js:142
    [apex-auctions]/[fp-ts]/lib/Task.js:142:37


success createSchemaCustomization - 1.337s
success Checking for changed pages - 0.001s
success source and transform nodes - 2.509s
success building schema - 1.639s
success createPages - 0.147s
success createPagesStatefully - 0.062s
info Total nodes: 261, SitePage nodes: 17 (use --verbose for breakdown)
success Checking for changed pages - 0.001s
success write out redirect data - 0.002s
success Build manifest and related icons - 0.119s

 ERROR

gatsby-plugin-prismic-previews(apex-auctions) - Type paths for this repository could not be found. Check that you have gatsby-source-prismic configured with the same repository name and type prefix (if used) in gatsby-config.js.

not finished onPostBootstrap - 0.130s


 ERROR

Four repos I'm mostly having issues with are apex-auctions, bidlogix, thejuniperstudio and parking4less

Thanks for sending over the details @thejuniperstudio.

We'll be looking over your case and come back as soon as we have more information.

@thejuniperstudio Thanks for sending all of those details, and sorry I wasn't able to take a look at this sooner.

I just published a new version of gatsby-source-prismic that should fix your issue.

  • gatsby-source-prismic: v5.1.1

The cause was due to unexpected missing Slice model fields. In some Slices, the repeat or non-repeat properties were missing. This could be something the editor produced at the time, so this isn't any fault of yours. Today, the editor will add both properties by default.

The updated plugin now supports models where those properties are missing.

This was tested with apex-auctions but please let me know if the other repositories are still experiencing the same issue with the updated plugin.

Thanks!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Hi,

I’ve got a similar issue with the following versions:

"gatsby": "^5.9.0",
"gatsby-source-prismic": "^5.3.0",
"gatsby-plugin-image": "^3.10.0",

I tried with / without specifying scheme and the error stays the same:

"gatsby-source-prismic" threw an error while running the createSchemaCustomization lifecycle:

Cannot read properties of undefined (reading 'slice')



  TypeError: Cannot read properties of undefined (reading 'slice')

  - graphqlTypes.ts:57
    [mahesh-bijoutier.ch-gatsby-v5]/[@imgix]/gatsby/src/modules/gatsby-plugin/graphqlTypes.ts:57:35

  - Array.reduce

  - graphqlTypes.ts:24 ImgixParamsInputType
    [mahesh-bijoutier.ch-gatsby-v5]/[@imgix]/gatsby/src/modules/gatsby-plugin/graphqlTypes.ts:24:54

  - typeBuilder.ts:55 buildImgixGatsbyTypes
    [mahesh-bijoutier.ch-gatsby-v5]/[@imgix]/gatsby/src/modules/gatsby-plugin/typeBuilder.ts:55:47

  - pluginHelpers.ts:16 Object.createImgixGatsbyTypes
    [mahesh-bijoutier.ch-gatsby-v5]/[@imgix]/gatsby/src/pluginHelpers.ts:16:24

  - buildImageBaseFieldConfigMap.ts:121
    [mahesh-bijoutier.ch-gatsby-v5]/[gatsby-source-prismic]/src/builders/buildImageBaseFieldConfigMap.ts:121:16

  - Chain.js:15
    [mahesh-bijoutier.ch-gatsby-v5]/[fp-ts]/lib/Chain.js:15:103

  - EitherT.js:83
    [mahesh-bijoutier.ch-gatsby-v5]/[fp-ts]/lib/EitherT.js:83:97

  - ReaderT.js:24
    [mahesh-bijoutier.ch-gatsby-v5]/[fp-ts]/lib/ReaderT.js:24:97

  - Task.js:133
    [mahesh-bijoutier.ch-gatsby-v5]/[fp-ts]/lib/Task.js:133:41

  - async Promise.all

  - create-schema-customization.ts:155 Object.createSchemaCustomization
    [mahesh-bijoutier.ch-gatsby-v5]/[gatsby-source-prismic]/src/create-schema-customization.ts:155:9

  - api-runner-node.js:509 runAPI
    [mahesh-bijoutier.ch-gatsby-v5]/[gatsby]/src/utils/api-runner-node.js:509:16

It looks like it comes from images. I disabled all of my content types to see if this was solving the issue but no. Also tried with another fresh and simple Prismic Repo but same behavior.

Does anybody have an idea on that one?

Thanks for your help!

Yassin

I noticed this started happening yesterday. It's on the latest version of Gatsby. They have done something to their slices which seems to conflict.

Downgrade to Gatsby 5.8 and fix at that version (and all associated official plugins) that seems to fix the issue for now.

Thanks for your reply! I downgraded every packages from 5.9.0 to 5.8.0 but still the exact same error...

Here is my dependencies:

"dependencies": {
    "@prismicio/react": "^2.6.2",
    "@styled-system/theme-get": "^5.1.2",
    "babel-plugin-styled-components": "^2.1.1",
    "formik": "^2.2.9",
    "gatsby": "^5.8.0",
    "gatsby-plugin-canonical-urls": "^5.8.0",
    "gatsby-plugin-catch-links": "^5.8.0",
    "gatsby-plugin-image": "^3.10.0",
    "gatsby-plugin-manifest": "^5.8.0",
    "gatsby-plugin-netlify-cms": "^7.9.0",
    "gatsby-plugin-polyfill-io": "^1.1.0",
    "gatsby-plugin-prismic-previews": "^5.3.0",
    "gatsby-plugin-react-svg": "^3.3.0",
    "gatsby-plugin-sharp": "^5.8.0",
    "gatsby-plugin-sitemap": "^6.9.0",
    "gatsby-plugin-styled-components": "^6.9.0",
    "gatsby-remark-images": "^7.9.0",
    "gatsby-remark-relative-images": "^2.0.2",
    "gatsby-remark-relative-images-v2": "^0.1.5",
    "gatsby-source-filesystem": "^5.8.0",
    "gatsby-source-prismic": "^5.3.0",
    "gatsby-transformer-javascript-frontmatter": "^5.8.0",
    "gatsby-transformer-remark": "^6.9.0",
    "gatsby-transformer-sharp": "^5.8.0",
    "gatsby-transformer-yaml": "^5.8.0",
    "luxon": "^3.3.0",
    "netlify-cms-app": "^2.15.72",
    "nl2br": "^0.0.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-dropdown": "^1.11.0",
    "react-markdown": "^8.0.7",
    "rehype-raw": "^6.1.1",
    "slug": "^8.2.2",
    "styled-components": "^5.3.10",
    "styled-reset": "^4.4.6",
    "styled-system": "^5.1.5",
    "typeface-eb-garamond": "^1.1.13",
    "typeface-open-sans": "^1.1.13",
    "yup": "^1.1.1"
  },
  "resolutions": {
    "sharp": "0.31.1",
    "babel-plugin-lodash/@babel/types": "^7.21.2"
  }

(I’m trying to migrate from Netlify CMS to Prismic as I’m stuck with the image Sharp transformation. That explain lots of dependencies I’ll get rid of as soon as I’ll be able to make my Prismic API calls)

Do you have any other idea? I can host a skeleton of my project on a repo if it helps.

Thanks!

I'm not a associated with Prismic but would happily take a look if you want to send over a link to your repo (or ghost repo)

It’s very kind.
You should be able to

git clone https://matiere-vive@bitbucket.org/matiere-vive/gatsby-v5-source-prismic.git
yarn install
yarn develop

Thanks!

Played around with the repo this morning, and someone else has come up with the fix already. - createSchemaCustomization lifecycle failing with Gatsby 5.10.0 · Issue #531 · prismicio/prismic-gatsby · GitHub

@yassin this worked on the repo you sent me.

Looks like @angeloashmore there might be a small fix needed here.

Nice thank you! It’s strange I didn’t come up to this ticket as I googled the exact same error message.
Appreciate your help!

Thanks for the tag @thejuniperstudio! :slight_smile:

Could you and @yassin try this alpha version of the plugin and let me know if it fixes the issue? I updated @imgix/gatsby in both plugins which seems to resolve the error on my end.

npm install gatsby-source-prismic@5.3.1-alpha.0 gatsby-plugin-prismic-previews@5.3.1-alpha.0

Thank you!

A user on GitHub confirmed the fix works for them. The fix has been merged and published in v5.3.1.

You can update to the latest version with the following commands:

npm install gatsby-source-prismic@latest
npm install gatsby-plugin-prismic-previews@latest

If this doesn't resolve the issue, please comment in the GitHub issue thread and I will take another look: createSchemaCustomization lifecycle failing with Gatsby 5.10.0 · Issue #531 · prismicio/prismic-gatsby · GitHub

Thank you again!

2 Likes