Can't update published document after draft loses "draft." prefix

8 replies
Last updated: Jun 7, 2022
Hello there đź––
We currently have a problem with Sanity datasets, actually, with one of the datasets.

In a particular document type, the user can start creating a document and it is saved as a draft, so far so good, once the document is published, the document id changes from
draft.123**456
to
123**456
, everything OK, as expected, but it does not allow to update it anymore. We have tried with the cli import script into another dataset we have and works, but not on this one.
Has anyone experienced a similar problem? Or do you have ideas on how to debug this better? Thanks in advance
AI Update

This sounds like a frustrating issue! The good news is that the draft-to-published ID change you're seeing (draft.123**456 → 123**456) is completely normal Sanity behavior. The problem where you can't update the published document could be caused by a few things:

Most Likely Causes

1. Dataset Read-Only Mode

First thing to check: Is your dataset in read-only mode? This can happen if:

  • The dataset was explicitly set to read-only in your project settings
  • You're on a plan that has dataset limits and something triggered a lock
  • There's a billing/payment issue

Check this at sanity.io/manage → Select your project → Datasets → Look for any read-only indicators or warnings.

2. Permissions/Role Issues

Since you mentioned it works in another dataset but not this one, check the permissions and roles:

  • Does the user/token have proper write permissions for this specific dataset?
  • Go to sanity.io/manage → Your project → API settings → Tokens (or Members)
  • Verify the role has "Update and Create" or "Publish" permissions for this dataset

If you're using custom roles (Enterprise feature), make sure the content resources aren't blocking updates to published documents.

3. Revision ID Conflicts (409 Errors)

If you're getting 409 conflict errors, this relates to optimistic locking and concurrency control. This happens when:

  • The document's _rev (revision ID) has changed since you last fetched it
  • Multiple clients are trying to update simultaneously
  • Your client is using stale data due to eventual consistency

Solution: Refetch the document before updating, or use the ifRevisionID parameter in your mutations to handle conflicts gracefully.

Debugging Steps

  1. Check the browser console/network tab when trying to update - look for 409, 403, 401, or 500 HTTP errors. The specific error code will tell you a lot.

  2. Try updating via the CLI to isolate if it's a Studio vs. API issue:

    sanity documents query '*[_id == "123**456"][0]'

    Then try a patch operation via the CLI to see if you get a more specific error message.

  3. Check dataset settings in Manage for any restrictions or warnings.

  4. Compare dataset configurations between the working and non-working datasets - look at permissions, roles, and any dataset-specific settings.

  5. Check for validation errors - Sometimes schema validation rules can prevent saves, though these usually show clear error messages in Studio.

Additional Considerations

  • If you recently migrated or imported data, verify that all document references are valid
  • Make sure your Studio version is up to date (npm outdated in your studio folder)
  • Check if there are any custom document actions or workflows that might be interfering

The fact that your CLI import script works in another dataset strongly suggests this is either a permissions issue or a dataset-level configuration problem rather than a bug with the documents themselves.

What to look for specifically: When you try to update the published document, open your browser's developer tools (Network tab) and look at the failed request. The HTTP status code and response body should give you the exact error message that'll point to the root cause.

Let us know what error messages you're seeing - that'll help narrow it down!

Show original thread
8 replies
Hi User. Are you using any document actions that set the document as read-only on publish?
hello
user A
not afaik, how can I check it?
Your sanity.json file would implement a part like
part:@sanity/base/document-actions/resolver
. The file in the path will contain (or import) the document action code.
In addition, it might help if you’re able to include your schema for that one document type.
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema"
    },
    {
      "name": "part:@sanity/desk-tool/structure",
      "path": "./desk-structure.ts"
    },
    {
      "implements": "part:@sanity/production-preview/resolve-production-url",
      "path": "./resolveProductionUrl.ts"
    },
    {
      "implements": "part:@sanity/base/theme/variables/override-style",
      "path": "./styles/variables.css"
    }
  ]
this is what we have right now
A fix has been implemented and this should now be resolved. Thanks for your patience, Luis.
could you please detail what the problem was and if it is solved forever or it could happen again, thank you in advance
It was an indexing issue, which we don’t see too often but it can happen. The team mentioned they will be prioritizing work on this to make it even less likely going forward.
great, many thanks
user A
for all your support on this!!

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?