Unknown document type: * error when creating new location documents in Sanity Studio
This error occurs when Sanity Studio can't resolve your document type properly - the * is essentially a placeholder indicating that the schema type couldn't be found or loaded. Since you mentioned this worked before and you have existing location documents, something in your schema configuration has broken.
Here are the most common causes and how to fix them:
1. Schema Not Properly Imported/Exported
The most frequent cause is that your location schema isn't being properly exported or imported in your schema configuration. Check your schema file (usually schema.js or schemas/index.js):
// Make sure your location schema is imported
import location from './location'
export default createSchema({
name: 'default',
types: schemaTypes.concat([
location, // ← Make sure this is included
// ... other types
])
})2. Circular Dependencies
If you recently added references or imports between schema files, you might have created a circular dependency that prevents the schema from loading properly. Check if your location schema imports anything that imports it back.
3. Syntax Error in Schema File
A JavaScript syntax error in your location.js schema file (or any schema file) can prevent the entire schema from loading. Even a small typo can break the whole schema compilation.
4. Schema File Not Saved or Studio Not Restarted
Sometimes it's as simple as:
- The schema file wasn't saved
- The Studio dev server needs to be restarted (
Ctrl+Cand restartsanity start) - Browser cache needs to be cleared (hard refresh with
Ctrl+Shift+RorCmd+Shift+R)
How to Debug
- Check the browser console - Open DevTools (F12) and look for JavaScript errors when Studio loads. This often reveals the root cause
- Verify the schema loads - Add a
console.log('location schema loaded')at the top of your location schema file to confirm it's being executed - Test in isolation - Temporarily comment out other schemas to see if there's a conflict
- Check for typos - Verify the
name: 'location'in your schema definition matches exactly what you're trying to create
Since you mentioned this worked before, try to recall what you changed recently - a new field, a reference to another document type, or any schema reorganization. That's likely where the issue was introduced.
Side note: You're on Studio v2.30.1 which is quite old. While this shouldn't cause this specific error, consider upgrading to Studio v3 when possible - it has much better error messages that would help diagnose issues like this more clearly.
Show original thread11 replies
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.