Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desk tool crashed when 0 translations remain #139

Open
thijs-justacodename opened this issue Jun 2, 2023 · 13 comments
Open

Desk tool crashed when 0 translations remain #139

thijs-justacodename opened this issue Jun 2, 2023 · 13 comments

Comments

@thijs-justacodename
Copy link

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.

@liam-nt
Copy link

liam-nt commented Jun 20, 2023

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

@Designer023
Copy link

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

@otomir23
Copy link

Same!

@klauschin
Copy link

Same here

LiamMartens added a commit that referenced this issue Aug 4, 2023
@marcinincreo
Copy link

+1

@yayinchang
Copy link

yayinchang commented Oct 4, 2023

@LiamMartens @SimeonGriggs the issue still exists.

@Almondzil
Copy link

@LiamMartens @SimeonGriggs the issue still exists:

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

@teguh77
Copy link

teguh77 commented Oct 15, 2023

this issue still exists, how to solve it?

@brennenrampton
Copy link

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.

@bobinska-dev
Copy link

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 :)

@brennenrampton
Copy link

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.

@LiamMartens LiamMartens reopened this Nov 1, 2023
@Danishsjjd
Copy link

Danishsjjd commented Nov 2, 2023

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

@notflip
Copy link

notflip commented Mar 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests