Error importing SVG file with invalid metadata in Sanity CLI
You're hitting an issue with SVG files during dataset import where the CLI is trying to extract metadata that doesn't exist in the same way for SVG files as it does for raster images (JPEG, PNG, etc.).
What's happening: Sanity's image asset pipeline does support SVG files - you can see in the image transformation documentation that SVG is a valid format and can even be converted to bitmap formats like PNG or JPG through the CDN. However, the import process attempts to read metadata (dimensions, color information, etc.) from uploaded assets, and SVG files as XML-based vector graphics don't contain this metadata in the same format as raster images.
Solutions to try:
Use the
--allow-failing-assetsflag when importing:sanity dataset import production-export.tar.gz production --allow-failing-assetsThis tells the CLI to continue importing even when asset uploads fail, so your documents will import successfully and only the problematic SVG assets will be skipped. You can then manually re-upload the SVGs afterward.
Consider using the
filetype instead ofimagetype for SVGs: Going forward, if you frequently work with SVG files, you might want to use thefilefield type in your schema rather thanimagetype:{ name: 'logo', type: 'file', title: 'Logo (SVG)', options: { accept: '.svg' } }The file type doesn't attempt to extract image metadata, which avoids this issue entirely.
Manual workaround for existing exports: If you need to import an existing export with SVGs:
- Extract the tar.gz file
- Remove the problematic SVG files from the images folder
- Re-compress and import with the remaining assets
- Manually re-upload SVGs after import completes
Host SVGs externally: For critical SVG assets, you could store them in your codebase or a CDN and reference the URL in Sanity rather than uploading them as assets.
The Slack thread you referenced is likely discussing the same limitation with how the CLI import handles SVG metadata extraction. While Sanity's CDN and transformation pipeline fully support SVG files once they're uploaded, the import process has this metadata extraction step that can fail for SVGs.
The --allow-failing-assets flag is probably your quickest solution to get your import completed without losing your document data.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.