Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Contentful Preview API wrongly includes `sys.locale` on response

See original GitHub issue

Expected Behavior

Contentful Preview API should be consistent with Contentful Delivery API in that when making a query such as:

    const response = await contentful.getEntries({
      content_type: 'navigation',
      locale: '*',
      include: 10,
      limit: 1,

The entries shouldn’t include sys.locale. This field shouldn’t exist when query is all locales. This has been working fine all the time and we’ve noticed that preview breaks for us today because we rely on sys.locale to figure out the type of response (if fields are localized)

Actual Behavior

The Contentful Preview API is including the sys.locale field when making a request with locale: '*'. This is an example response’s entry from Contentful Preview API with the above ☝️ query:

  sys: {
    space: { sys: [Object] },
    type: 'Entry',
    id: '********',
    contentType: { sys: [Object] },
    revision: 26,
    createdAt: '2020-05-18T11:47:03.837Z',
    updatedAt: '2020-06-05T15:23:52.346Z',
    locale: 'en', // <<<<<<<<<< This shouldn't have been included (Delivery API doesn't include it)
    environment: { sys: [Object] }
  fields: {
    title: { en: '*******' },
    navigation: { de: [Object], en: [Object], fr: [Object], nl: [Object] },
    footer: { de: [Object], en: [Object], fr: [Object], nl: [Object] }

Possible Solution

Remove the sys.locale from entries when request query includes all locales locale: '*' as it has been before … today 🙈 (not sure exactly when this was introduced but it worked before today). Luckily, Contentful Delivery API wasn’t broken so our site is still alive.

Steps to Reproduce

  1. Create a Contentful Model
  2. Create a few fields and mark them as localized
  3. Create an entry
  4. Use Contentful Preview API to make a request (use the query provided above ☝️)
  5. Check response’s entries’ sys.locale


Our site allows to switch to a preview mode which basically just uses Contentful Preview API. After today, we no longer can access the preview version because we rely on sys.locale on entries to figure out if the response has localized fields (For example, if query was with locale: '*' or locale: 'en')


  • Language Version: Node v12.16.2
  • Package Manager Version: Yarn 1.22.4
  • Operating System: MacOS, Linux (deployed to Vercel, not sure what Linux OS runs under)
  • Package Version: contentful@7.14.4
  • Which API are you using?: Delivery (works as expected) / Preview (fails as explained above)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

eddywcommented, Jun 19, 2020

@gburgett I opened a ticket with Contentful support yesterday and today they let me know that this was fixed. I’m testing before sending a reply but so far it seems that all is working again for us. It’d be great if you could verify with your team.

marcolinkcommented, Sep 10, 2020

As this seems fixed, I will close it for now. Feel free to open it again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors | Contentful
HTTP status code Error code Description 401 Unauthorized AccessTokenInvalid The authorization token was invalid. 422 Unprocessable Entity UnknownField The triggered query references an unknown... 422 Unprocessable...
Read more >
Resolving links fails when using getEntries with locale * #186
So it seems either the implementer of the contentful package has mistaken assumptions about the API or the API is broken. All reactions....
Read more >
Webhooks and autosave - APIs - Contentful Community
Hi We're using webhooks on autosave to save contents in a database and be able to have a preview of our website. We're...
Read more >
Next.js + Contentful Preview Mode setup walkthrough - YouTube
One challenge when working with statically generated content is how to allow editors to preview their changes before publishing to ...
Read more >
Troubleshooting Common Errors - Gatsby
Field "image" must not have a selection since type "String" has no subfields; Problems installing sharp with gatsby-plugin-sharp - gyp ERR! build error ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found