Draft document deleted via CLI still showing in desk tool's main document list
10 replies
Last updated: Jun 16, 2023
N
I have a draft document that was created via the Sanity client like this:
It was then deleted via the CLI but is still showing up in the desk tool's main document list for the doc type. The CLI and Vision both confirm the document does not exist, yet is still showing. This is happening on
transaction .createIfNotExists(document) .patch(draftId, patch => patch.set(document));
v2.34. Any ideas on how to resolve this?
Jun 16, 2023, 5:33 PM
Hi
user A
. It’s possible that the draft (with an _idof
drafts.document) still exists.
Jun 16, 2023, 5:40 PM
N
Thanks for the reply
user A
. How can I delete it? Also why is the document with drafts.path showing in the main list, and in the browser URL? I haven't seen that behaviour before.
Jun 16, 2023, 5:42 PM
Actually, I missed your mention of it being a draft in your initial post. I’m not entirely sure I’m following your process. Please let me know if I have this right:
1. You created a draft document in the client that had an
.2. You opened that document in the Studio, and the
.4. The document remains in the Studio’s document list, even though
returns no results in Vision nor the CLI.If you open the document in the Studio and inspect the JSON, what’s the
1. You created a draft document in the client that had an
_idof
drafts.451f5de0-b1fc-4a2d-a92d-f58f9f84c160
drafts.prefix was in the URL.3. You deleted the document via the CLI with the command
sanity documents delete "drafts.451f5de0-b1fc-4a2d-a92d-f58f9f84c160"
drafts.451f5de0-b1fc-4a2d-a92d-f58f9f84c160
_id?
Jun 16, 2023, 5:50 PM
N
yes that process is correct. for one document, the URL shows the drafts path, but inspecting the JSON shows the published _id:
Jun 16, 2023, 5:55 PM
N
For the other document, the URL shows the drafts path, but the JSON shows no _id field at all. there is also no title field, even though the title is showing in the document list.
Jun 16, 2023, 5:56 PM
N
URL:
drafts.c8a12195-35c7-4217-9475-33bb697fa73a
Jun 16, 2023, 6:02 PM
N
JSON:
Jun 16, 2023, 6:02 PM
N
user A
I think I figured out what was happening. The ID being used to patch the draft document could either be the published document's ID, or the draft ID. In the case where it was the draft ID, a new document with the ID of drafts.drafts.c8a12195-35c7-4217-9475-33bb697fa73a
draftsversion of the document, and update the transaction code so that doesn't happen now.
Jun 16, 2023, 9:53 PM
Wild! I’ve never come across that happening before, but I guess
drafts.drafts.IDstill fits the Studio’s expectation of a draft
_id. Thanks for updating to let me know, and I’m glad you got it worked out!
Jun 16, 2023, 9:55 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.