document-internationalization icon indicating copy to clipboard operation
document-internationalization copied to clipboard

Desk tool crashed when 0 translations remain

Open thijs-justacodename opened this issue 2 years ago • 13 comments

When manually attempting to fix a translation association, we ended up with a translations.metadata document with 0 translations. This caused the Desk tool to crash, and as a result the issue cannot be resolved.

Error: undefined is not an object (evaluating 'translations.length')

DeleteMetadataAction@.../node_modules/.sanity/vite/deps/@sanity_document-internationalization.js:7290:36
HookStateContainer2@.../node_modules/.sanity/vite/deps/chunk-QYVNDX4Z.js:74462:25
renderWithHooks@.../node_modules/.sanity/vite/deps/chunk-CG7IQCDB.js:12171:35

This occurs with sanity v3.11.5 and document-internationalization v2.0.0

I can imagine that this issue only occurs through manual intervention in Translation metadata, however, there is no way to escape this state.

thijs-justacodename avatar Jun 02 '23 07:06 thijs-justacodename

Also get a similar error when deleting both translations from the Translations > Manage Translations panel: Error: Cannot read properties of undefined (reading 'length')

liam-nt avatar Jun 20 '23 12:06 liam-nt

Same here.

Also get a similar error when deleting both translations from the Translations > Manage Translations panel: Error: Cannot read properties of undefined (reading 'length')

I also get this issue when I have no translations.metadata document with 0 translations. There is no way to get in and delete the metadata or add a translation.

This either happens when I remove a translation, or when I select a document type with no documents selected under translations

Designer023 avatar Jul 04 '23 10:07 Designer023

Same!

otomir23 avatar Jul 30 '23 15:07 otomir23

Same here

klauschin avatar Jul 31 '23 04:07 klauschin

+1

marcinincreo avatar Sep 07 '23 12:09 marcinincreo

@LiamMartens @SimeonGriggs the issue still exists.

yayinchang avatar Oct 04 '23 04:10 yayinchang

@LiamMartens @SimeonGriggs the issue still exists:

@sanity/document-internationalization v2.0.1, sanity v3.17.0

Almondzil avatar Oct 08 '23 18:10 Almondzil

this issue still exists, how to solve it?

teguh77 avatar Oct 15 '23 06:10 teguh77

Just got into the same issue while setting up translations for a new site. Would really appreciate a way to get out of this error other than making a new dataset.

brennenrampton avatar Oct 26 '23 04:10 brennenrampton

Hello everyone, for more help and workarounds we usually send people to our community. Since I have a small script you can use to get the meta translation documents without references set and delete them, here is what you can do:

client
      .delete({query: "*[_type == 'translation.metadata' && !defined(translations)]"})
      .then(() => {
        console.log('The document matching the query were deleted')
      })
      .catch((err) => {
        console.error('Delete failed: ', err.message)
      })

afterwards you will be unblocked again :)

bobinska-dev avatar Oct 30 '23 16:10 bobinska-dev

Hello everyone, for more help and workarounds we usually send people to our community. Since I have a small script you can use to get the meta translation documents without references set and delete them, here is what you can do:

client
      .delete({query: "*[_type == 'translation.metadata' && !defined(translations)]"})
      .then(() => {
        console.log('The document matching the query were deleted')
      })
      .catch((err) => {
        console.error('Delete failed: ', err.message)
      })

afterwards you will be unblocked again :)

Thank you! It worked great.

brennenrampton avatar Oct 31 '23 15:10 brennenrampton

this issue still exists, I don't find a way to fix it.

danishsjjd avatar Nov 02 '23 12:11 danishsjjd

Hello everyone, for more help and workarounds we usually send people to our community. Since I have a small script you can use to get the meta translation documents without references set and delete them, here is what you can do:

client
      .delete({query: "*[_type == 'translation.metadata' && !defined(translations)]"})
      .then(() => {
        console.log('The document matching the query were deleted')
      })
      .catch((err) => {
        console.error('Delete failed: ', err.message)
      })

afterwards you will be unblocked again :)

I'm pretty new to Sanity, where do I put this code? I also noticed that when I delete a certain model, the translations will still be floating around.

notflip avatar Mar 13 '24 12:03 notflip