gatsbyjs/gatsby · error

FetchContentTypes

FetchContentTypes

Error message

Restricted ContentType name found. The name "${contentTypeItemId}" is not allowed.

What it means

Validation guard in getContentTypesFromContentful: while assigning each content type an identifier (its name when useNameForId is true, otherwise its internal id), the chosen id collides with one of Gatsby's reserved type names — 'entity', 'reference', 'asset', and additionally 'tag' when enableTags is on. Such a name would clash with the plugin's own internal node types and break schema generation, so the build panics. The input at fault is the content type's name/id defined in the Contentful space.

Solutions

  1. Rename the Contentful content type to avoid restricted names (names that collide with Gatsby internal types such as Node or names starting with reserved prefixes).
  2. Create a new content type in Contentful with an allowed name and migrate the entries.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby-source-contentful/src/create-schema-customization.js:54 when the library encounters an invalid state.

Common situations: Occurs when a Contentful content type uses a reserved/restricted name (e.g. 'ContentType'). Rename the content type in Contentful to avoid restricted identifiers.


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/1b1744ddc10e6a75. Report an issue: GitHub.

Appendix: source

Thrown at packages/gatsby-source-contentful/src/create-schema-customization.js:54

  // Check for restricted content type names and set id based on useNameForId
  const useNameForId = pluginConfig.get(`useNameForId`)
  const restrictedContentTypes = [`entity`, `reference`, `asset`]

  if (pluginConfig.get(`enableTags`)) {
    restrictedContentTypes.push(`tag`)
  }

  contentTypeItems.forEach(contentTypeItem => {
    // Establish identifier for content type
    //  Use `name` if specified, otherwise, use internal id (usually a natural-language constant,
    //  but sometimes a base62 uuid generated by Contentful, hence the option)
    let contentTypeItemId = contentTypeItem.sys.id
    if (useNameForId) {
      contentTypeItemId = contentTypeItem.name.toLowerCase()
    }

    if (restrictedContentTypes.includes(contentTypeItemId)) {
      reporter.panic({
        id: CODES.FetchContentTypes,
        context: {
          sourceMessage: `Restricted ContentType name found. The name "${contentTypeItemId}" is not allowed.`,
        },
      })
    }
  })

  // Store processed content types in cache for sourceNodes
  const sourceId = `${pluginConfig.get(`spaceId`)}-${pluginConfig.get(
    `environment`
  )}`
  const CACHE_CONTENT_TYPES = `contentful-content-types-${sourceId}`
  await cache.set(CACHE_CONTENT_TYPES, contentTypeItems)

  return contentTypeItems
}

View on GitHub (pinned to 8b06340921)