Issue with newly imported dataset not reflecting in Sanity CMS modules

14 replies
Last updated: Sep 14, 2022
Hello all! This morning we launched our new brand to our Sanity CMS powered site 🎉 . We have run into something interesting. When we started the brand work we imported our production dataset into our development dataset to start making changes that weren’t live to the public. This morning we imported that development dataset we worked on to our production dataset using the CLI . The website is accurate in every way to the dataset we deployed, however, the modules in the Sanity CMS when targeting the new production dataset still reflect the old production dataset, not the one that was newly imported. I don’t know how the Sanity CMS picks up the dataset import, but this wasn’t an issue when we imported production into development the first time. Any ideas how we can get our CMS up to date?
AI Update

Congratulations on the launch! 🎉

The issue you're experiencing is likely related to Studio configuration, not a data import problem. Since your website is showing the correct content, the dataset import was successful. The Studio showing old data suggests it might be pointing to the wrong dataset or there's a configuration mismatch.

First: Verify Your Studio Configuration

Check your sanity.config.ts (or sanity.config.js) file to ensure it's pointing to the correct dataset. According to the defineConfig documentation, your configuration should look like this:

import { defineConfig } from 'sanity'

export default defineConfig({
  projectId: 'your-project-id',
  dataset: 'production', // Make sure this matches your target dataset
  // ... rest of config
})

If you're using environment variables to manage different datasets, verify that your production Studio is using the correct environment configuration. Check for .env files that might be overriding your dataset setting:

SANITY_STUDIO_API_DATASET="production"

Understanding Dataset Imports

When you use the CLI to import a dataset (with commands like sanity dataset import), you're updating the Content Lake - the actual data storage. Your Studio then queries this data through Sanity's API. The datasets documentation explains that datasets are "named isolated collections of schemaless JSON documents" that are completely separate from each other.

Troubleshooting Steps

  1. Verify the import completed successfully: Check your CLI output for any errors during the import process

  2. Confirm you're viewing the correct dataset: If your Studio supports multiple datasets or workspaces, make sure you haven't accidentally switched to a different one

  3. Redeploy your Studio: If your Studio is hosted on Sanity's platform, try redeploying it:

    sanity deploy
  4. Check for dataset name mismatches: Ensure the dataset name in your Studio config exactly matches the dataset you imported to (including any differences in capitalization or spacing)

  5. Restart your local development server: If you're running the Studio locally with sanity dev, stop and restart the development server

About the --replace Option

When using sanity dataset import with the --replace flag, it completely replaces the target dataset's contents with the imported data. This is a destructive operation that removes all existing documents before importing the new ones. The fact that your website shows correct data confirms this worked as expected.

The Studio should immediately reflect changes in the Content Lake since it queries the data in real-time through the API. If it's not showing updated content, it's almost always a configuration issue rather than a data synchronization problem.

If none of these steps resolve the issue, double-check that you imported to the exact dataset name that your production Studio is configured to use - even small typos or naming differences would cause this exact symptom you're seeing.

I have tried a redeploy of the Sanity CMS, but this had no effect. I admittedly don’t fully understand how Sanity CMS utilizes the dataset or if there’s some caching going on somewhere.
could you give us a mote detailed info around your datasets and how the “new production dataset still reflect the old production dataset” looks like?This could be caused by so many things, so the more you can share the better
Hey
user J
thanks for the reply!Datasets: We have two separate datasets, development and production. When we did our brand relaunch we had our content team make updates exclusively to our development dataset. There were breaking changes in the brand relaunch that we didn’t want to break our public facing website (new modules, assets, etc
).

What we did:
1. Create a development instance of our website complete with a development dataset, a sanity instance, and a gatsby frontend. This was an exact replica of the production dataset, sanity instance, and gatsby front end.
2. Use these development resources or “development environment” to make updates to the development dataset, gatsby frontend and sanity instance.
3. On the day of the launch. Merged changes from development to production for the sanity instance and gatsby front end. Exported the current development dataset using the command
sanity dataset export
and then imported the development dataset into the production dataset with the command
sanity dataset import data.ndjson production --replace
where the data.ndjson was the data we just exported from the development dataset.4. After doing so we viewed our gatsby site and it was identical to the development gatsby site meaning it built the website with the production dataset that we just imported from development. When we go into the Sanity CMS however, the modules still reference the content that was supposedly overwritten by the import from development into production. As an example our content changed from “The modern medical home for women” to “The new standard of care for women”, but within the CMS the module still says “The modern medical home for women” despite the live website showing the new tagline.
5. After this happened we tried redeploying the sanity instance and GraphQL API, but neither seems to have fixed the issues in the CMS.
Adding my colleague
user L
to follow the thread here.
This seems very strange
 And if you query the content in Vision, it’s the new one, but in the studio it shows the old data? Could you also check the versions panel of documents as well as any more things like console logs etc. and report back?
The investigation is on
đŸ•”ïžâ€â™€ïž
If you’re comfortable with it, you can also invite me into your project until we find whats going on.
Thanks
user J
,
user L
will take a look. We definitely saw the version change after the import. I’m not familiar with “Vision” you mean by querying the GraphQL API directly?
Hi! Nice to meet you
user J
. Sorry for late response. I figured out the problem. The thing was that before importing development dataset to production we had unpublished content in production dataset and because of that we could see new content in gatsby hosted website but the content shown in sanity CMS was the unpublished(draft) content. The only thing that looks strange is that in version history panel it shows importing new content as latest change but in view draft content(which was done before importing data) is being shown.
Hello
user L
👋Wonderful you figured it out!
Drafts would habe been my guess as well this is why I asked about vision and querying the data in the studio to see if drafts show up there.
I am unsure though, what you mean with the history panel.... Could you give more info around this please (I love screenshots
😉)
And btw. Since there are a lot of galls in here as well, we don't use guys so much as folks, you all etc
đŸ„Č I would be really thankful as well as all other fem and non-binary people in this community đŸ„°
This is the version panel that I am referring to.
Yeah I know it 😎 But what is the issue with it?
I am not sure that it is an issue but the latest version(newly imported dataset) doesn't match the shown content in CMS.
I guess it should work that way because of drafts. If it is, then everything is clear to me now)
Yeah drafts will always be shown first 🙂 If you have a green (aka active) Publish button, you are looking at a draft. In that case you can batch delete any drafts from your dataset via CLI command and a groq query, since you’re able to query for only drafts via the vision. BUT PLEASE BE CAREFUL 😉 deletions can be hard to get back
Got it! Thank you! â˜ș
Thank you so much for the help
user J
and
user L
for the investigation!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?