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.