🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Error when trying to publish a document of a "settings" schema in Sanity.io.

14 replies
Last updated: Jul 6, 2023
I'm getting an error when trying to publish a document of a "settings" schema (singleton):

Mutation(s) failed with 1 error(s): - document "settings": immutable attribute "_type" may not be modified
The schema is similar to the ones in the
official templates . Why can't I publish the document? Have I changed something along the way that caused this?
Jul 6, 2023, 8:45 PM
Interesting. This doesn’t seem easy to replicate. I can only do it by creating a draft via the CLI with an
that matches an existing document (e.g.,
, assuming
exists) and with a different
than the published version. Do you know the steps you took to lead up to this point?
Jul 6, 2023, 9:08 PM
Unfortunately, no. Maybe some dev changed something in the schema at some point and saved, but I can't make anything out of it. Should I re-create the schema from scratch?
Jul 6, 2023, 9:28 PM
Changing the schema name didn't help
Jul 6, 2023, 9:29 PM
Is the document’s
literally ‘settings’?
Jul 6, 2023, 9:34 PM
Jul 6, 2023, 9:35 PM
Perfect. What do you get in Vision when you query:

*[_id == 'drafts.settings']
Jul 6, 2023, 9:35 PM
_type: siteSettings
is me trying to rename it to see if it works
Jul 6, 2023, 9:36 PM
Which one matches your schema?
Jul 6, 2023, 9:37 PM
settings 🙂
Jul 6, 2023, 9:37 PM
Perfect. I would run this command in your terminal (from within the Studio directory) to nuke the draft.

sanity documents delete 'drafts.settings'
Jul 6, 2023, 9:38 PM
The error was coming from trying to mutate the published document with a different
, which the Content Lake doesn’t permit.
Jul 6, 2023, 9:39 PM
Ok, now to some CLI config issues hehe but I see your point. This should fix it!
Jul 6, 2023, 9:42 PM
user A
It worked, thank you so much!
Jul 6, 2023, 9:49 PM
Great! You’re welcome!
Jul 6, 2023, 9:52 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?