🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Import: Asset has different target than source

This error usually occurs when you have exported a dataset using sanity dataset export using the --raw flag, and then importing to a different project ID or dataset name.

The reason why this is failing is because the imported documents would refer to assets outside of it's own dataset, which is usually not what you want. If you delete an asset from the source dataset, it would create a "loose" asset document in the target dataset, which points to a file that no longer exists.

The solution is to not use --raw when exporting, which will also export all the assets from the source dataset. This will make sure the assets are also present in the target dataset when importing.

In very rare cases, you may want to allow the assets to reference URLs from a different dataset, in which case you can use the --allow-assets-in-different-dataset flag when importing.

Was this article helpful?