gatsby-source-contentful build fails if "localized" isn't present on content model #38445
Open
2 tasks done
Labels
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
type: bug
An issue or pull request relating to a bug in Gatsby
Preliminary Checks
Description
Ran into an issue today when building a fresh project with an older (migrated) contentful space.
I believe the issue was that the
localized
key wasn't attached to the content model response. Resolved the issue after a lot of digging by using the contentful CLI to set localized manually. Followed this guide from contentfulI can't provide a reproduction but I can provide you with the specific error and what I believe is the line in question causing the problem. Based on the error output being in
noramize.js
I did a quick search forlocalized
in the gatsby-source-contentful codebase and found the specific line that would (probably break) if it was undefined. My suggestion is add optional chaining. tofieldProps?.localized
Source: https://github.com/gatsbyjs/gatsby/blob/fd8de341684df7aa5fcd911a25786beac471925c/packages/gatsby-source-contentful/src/normalize.js#L507C52-L507C52
Reproduction Steps
Line In noramize.js that unsafely expect's a localized value to be present
I can't provide a reproduction but I can provide you with the specific error and what I believe is the line in question causing the problem.
(If you have tests of a mocked up contentful response, try deleting the
localized
key and see if it passess)https://github.com/gatsbyjs/gatsby/blob/fd8de341684df7aa5fcd911a25786beac471925c/packages/gatsby-source-contentful/src/normalize.js#L507C52-L507C52
Environment
Config Flags
None
The text was updated successfully, but these errors were encountered: