Issue creating a document in Sanity Studio due to invalid schema
This error happens when you have a document in your Content Lake that references a schema type that doesn't exist in your current Studio configuration. The asterisk (*) in the error message is a placeholder for the actual schema type name.
Here are the most common causes and solutions:
1. Missing schema type in your config
The schema type needs to be defined and registered in your sanity.config.js file. Check that you've included the schema type in your configuration:
import { defineConfig } from 'sanity'
import { deskTool } from 'sanity/desk'
import mySchemaType from './schemas/mySchemaType' // Import your schema
export default defineConfig({
// ... other config
schema: {
types: [mySchemaType] // Make sure it's registered here
}
})2. Schema was removed but documents still exist
If you previously had a schema type defined and then removed it, documents of that type still exist in your dataset. You have two options:
- Add the schema back: Re-add the schema type definition to your config
- Delete the orphaned documents: Use the Management API or Vision plugin to find and delete documents with that type
3. Working across different branches/environments
If you're working with multiple developers or environments, someone may have created documents with a schema type that hasn't been synced to your local Studio yet. Pull the latest schema definitions from your repository.
4. Typo in the schema type name
Double-check that the name field in your schema definition matches exactly what's being referenced. Schema type names are case-sensitive.
To identify which specific schema type is causing the issue, you can use the Vision plugin to query your documents and see what types exist:
*[!(_id in path("_.**"))] | order(_type) { _type }This will show you all document types in your dataset, helping you identify any mismatches with your local schema configuration.
Hope this helps! 🎉
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.