Retrieving a migrated record/document not working

I've just uploaded a record with the prismic migration. It's up in the migration release section. So far so good.

Let's say, that I that I've made a mistake with one of the fields and I want to update that.

When I download the current record with the prismic write client I get a "NotFoundError: No documents were returned" despite the document existing and using the same uid.

Addendum:

I've just noticed that after having published the erroneous record it all of a sudden can be found.

But that does not make sense at all. I want to be able to correct errors before they are being published, not afterwards.

Hi @MikeRophone,

Thank you for reaching out and providing detailed information about the issue.

The behavior you’re encountering is expected due to how unpublished documents are handled in Prismic. When a document is first created or updated through the Migration API, it exists in the “draft” state and is tied to the migration release. In this state, the write client queries won’t find the document unless it has been published or explicitly queried through the release. This is because unpublished documents are scoped to the release they are associated with.

Here’s how you can handle this situation:

  1. Querying a Draft Document in a Release: If the document is still in the draft state within a specific release, you need to include the release ID in your query to access it. This ensures the query is scoped to the correct release.

  2. Correcting the Field Before Publishing: To update an unpublished record:
    • Ensure you’re querying with the release ID where the document resides.
    • Use the updateDocument method to make corrections to the fields.
    • Save the changes back to the draft state within the same release.

  3. Publishing as a Final Step: Once all corrections are made and verified, you can proceed with publishing the document.

If you’d like, I can provide a code example or further clarify how to query drafts tied to a specific release. Let me know!

Finally I think it's a good idea for me to bring to my team that this process should be easier for you to manage with a standard release ID for migration releases.