Migration API with @prismicio/client issue when creating documents with slices field type check fails unexpectedly

Describe your question/issue in detail

I'm using the Migration API to export a Prismic repository to another fresh Prismic repository. I followed this very clear tutorial from Prismic Team but I'm having some errors while creating a document that contains slices.

Here a screenshot of the first error : "The value must be a number"

I went through my data file and discovered that the field in question is a number : 0

I took the time to check every field where this error was happening and same goes for all of them.

I tried some different documents and I had a different error but very similar : "The value must be a string"

Once again I looked up the data and turns out the field related is an empty string :

My guess is that the condition that validates the type of a field in a slice is using something like :

if (!value) return new Error()

which could return an error in the case of an empty string or a number equal to 0..?

Impacted feature

Migration API slices content type check

Package.json file

4 Likes

I've also had most of these issues while using the Migration API.

Same here... Hitting a wall - any help would be much appreciated!

I'm in the same boat regarding most of these issues... any assistance would be truly appreciated!

I'm also getting same problems. It's not useful Migration API without covering all these problems !

Hi everyone, @delabordemichael, @bonjour1, @antoine.galy.lamon, @ali,

Thank you for reporting this! I'm going to investigate what's happening and try to figure out what's happening here. Are you all getting the exact same issue as the one in @leo2's post, with the value must be a number (for number: 0) and the value must be a string (for an empty string), or are you running into different/general issues with the Migration API?

@ali you mentioned bookmarks in another forum post - is this something you're trying to migrate specifically and you're running into this issue?

Any little detail on what you're doing and what you want to be doing helps, so feel free to elaborate as much as you're able on what you've been dealing with :slight_smile: Thanks everyone.

Hi @Ezekiel thanks for looking into this! Trying to add more details :

  • Error happens right after on "documents:updating" event from the reporter on a document that includes slices with empty strings or number 0 value.
  • Error happens with master locale & alternative locale
  • Error error happens even if I only create documents using master locale
  • I followed precisely the tutorials provided by Prismic team regarding Migration API
  • Documents creations & update works fine with all documents other than the ones with empty strings or number 0 in slices array

I really need to make this migration work. I have more than 200 documents to migrate so manual operations is not an option. For now this is the only blocking issue but while writing my migration script I ran into several other issues that I'd be happy to share after this is fixed. Do you have some kind of feedback program going on for the Beta feature? I'm also curious about why the previous import/export feature is already removed while the new Migration feature is still Beta?

Thanks again

To give even more details, after digging again a bit more, I see that the issue occurs with rich texts :

On this document look at the "Title" field

The error is happening on the third line of the rich text : "Médailles Paralympiques"

Thanks for you @Ezekiel for this quick replay. Yes I discovered this problem when trying to do a repo migration . After a deep investigation, I had resolved the problem. It's related with creating a custom type to the new Prismic repo. The turnaround is to use the slice machine to update this custom type.
Similar custom types has been created without any problem with Migration API. I don't have any explanation.
I guess this problem can happen for other user.

The big challenge I get now is about updating Assets ids. When we use a little bit custom type, migration become not trivial.
I get many message errors around ; Assets with following ids not found error message.

1 Like

Hi everyone,

We take your feedback on the migration API seriously and will do our best to act upon them.

We tried to reproduce the original issue of this thread (The value must be a string/number) that seems to occur with rich text fields but were not able to reproduce it with minimal setups unfortunately.

We're happy to help you investigate this issue further if you're able to provide more information about your setups (package versions used, code snippets, etc.).

Trying to log the full content of the documents:updating events sent by the reporter (and/or providing a custom fetch function to the write client in order to log fetch calls' body) could also help understand what is actually getting sent to Prismic.

const writeClient = createWriteClient("repository", {
  writeToken: "***",
  fetch: (url, options) => {
    console.log(url, options)

    return fetch(url, options)
  }
})

// ...

writeClient.migrate(migration, {
  reporter: (event) => console.log(JSON.stringify(event, null, 2))
})

Lucie

A note regarding custom types creations (JSON defining the content shape of documents for Prismic), those are not handled by the migration API and should be created on the new repository prior to using the migration API through Slice Machine.

Hi @lihbr, thanks a lot for looking into this. I tried on my side to reproduce the issue with a minimal setup and it helped me figuring out that the error was on my side. I was parsing the data a certain way to setup the links to migration assets and documents relationships and something was wrong on ths side. When removing this parsing the error on the slice wasn't happening anymore. I hope this explanation can help anybody that encounters a similar issue. Thanks a lot for the assistance and sorry for blaming Prismic!!

However as I mentioned before I have some feedbacks to give about the migration API, is there a specific place to do it? Or should I create new topics for each?

2 Likes

Thank you @leo2, we appreciate you getting back to us about it and the explanation. I also hope it helps someone else! :slight_smile:

We're very interested in the feedback you have to give, can you create a new topic for each? Thanks!

1 Like