Deleting a translation document with self-reference error
16 replies
Last updated: Sep 22, 2022
A
Issue deleting a translation document that has reference to itself in another language. I tried to delete via Sanity Cli
sanity documents deletebut same error. Any advice?
Details the mutation(s) failed: Document "ElLnRMEzVGBvCslc1mXoT__i18n_es" cannot be deleted as there are references to it from "ElLnRMEzVGBvCslc1mXoT"
Sep 22, 2022, 6:28 PM
Hey
user P
! You need to remove that reference from the document before deleting.Sep 22, 2022, 6:29 PM
A
How do I remove the reference of the page itself?
Sep 22, 2022, 6:30 PM
A
The document I want to delete is a Spanish version of the English page
Sep 22, 2022, 6:31 PM
A
There is no option to remove the reference (?)
Sep 22, 2022, 6:31 PM
A
The document I want to delete is a Spanish version of the same page in English
Sep 22, 2022, 6:32 PM
A
Thanks will read it up
Sep 22, 2022, 6:41 PM
I should note that the readme I linked is more about how to control this behavior in the future, but not so helpful in your current situation 😅
Sep 22, 2022, 6:51 PM
A
Based on the readme, I do have
referenceBehaviorset to strong. Updating it to weak doesn’t help in this case since the reference was set earlier when the translated document was created.
Sep 22, 2022, 6:55 PM
A
If I understood correctly based on https://www.sanity.io/docs/js-client#removing-unsetting-fields
I should unset (remove) the reference field to
I should unset (remove) the reference field to
ElLnRMEzVGBvCslc1mXoTfrom the Spanish document id
ElLnRMEzVGBvCslc1mXoT__i18n_es
Sep 22, 2022, 6:56 PM
A
From the Spanish document
ElLnRMEzVGBvCslc1mXoT__i18n_esI can see
__i18n_base(containing reference to
ElLnRMEzVGBvCslc1mXoTis the field I shall remove using the API .What are you referring to when you said manually?
Sep 22, 2022, 7:05 PM
Manually means you've set an actual schema inside of your studio's UI to remove it. It doesn't seem like that's the case here.
Sep 22, 2022, 7:06 PM
A
Confirming deleting the reference field via API enable manual delete of the document later 🙂
Sep 22, 2022, 7:22 PM
A
Thanks for the tip!
Sep 22, 2022, 7:22 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.