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.

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...


"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

  - typePaths.ts:42

  - Array.flatMap

  - typePaths.ts:41 fieldToTypePaths

  - typePaths.ts:115

  - Array.flatMap

  - typePaths.ts:114 customTypeModelToTypePaths

  - runtime.ts:110

  - Array.flatMap

  - runtime.ts:109 Runtime.registerCustomTypeModels

  - create-schema-customization.ts:105

  - Chain.js:5

  - EitherT.js:52

  - ReaderT.js:18

  - Task.js:142

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


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


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.


1 Like

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