Unknown document type: * error when creating new location documents in Sanity Studio

11 replies
Last updated: Jul 11, 2022
I'm getting the following error immediately after trying to create a new
location
document in Sanity Studio (v2.30.1).

Unknown document type: *
This document has the schema type *, which is not defined as a type in the local content studio schema.

Here is the JSON representation of the document:
{
  "_type": "location"
}
Creating new
location
documents has worked before (I have many existing
location
documents up already).I'm not sure what I changed to cause this error.
Any insights as to what's going on (what is
*
referring to?) or how to debug this would be greatly appreciated!
AI Update

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+C and restart sanity start)
  • Browser cache needs to be cleared (hard refresh with Ctrl+Shift+R or Cmd+Shift+R)

How to Debug

  1. Check the browser console - Open DevTools (F12) and look for JavaScript errors when Studio loads. This often reveals the root cause
  2. 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
  3. Test in isolation - Temporarily comment out other schemas to see if there's a conflict
  4. 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 thread
11 replies
How are you importing that document into your schema?
I'm importing the
location
document the same as my other documents like this (
location
is at the top):

// Document types → Page Related
import location from './documents/location'
import menu from './documents/menu'
import menuSpecial from './documents/menu-special'
import groupLocation from './documents/group-location'
import groupMenu from './documents/group-menu'
import groupVenueArea from './documents/group-venue-area'
import brand from './documents/brand'
import redirect from './documents/redirect'
import tag from './documents/tag'
import category from './documents/category'
import post from './documents/post'
import postTag from './documents/post-tag'
import event from './documents/event'
import partnership from './documents/partnership'
Then utilizing the imports as below (partial snippet):


export default createSchema({
  // The name of our schema
  name: 'content',

  types: schemaTypes.concat([
    /* ----------------- */
    /* 1: Document types */

    // Meta
    page,
    generalSettings,
    promoSettings,
    headerSettings,
    footerSettings,
    seoSettings,
    navMenu,

    // Page Related
    location,
    menu,
    menuSpecial,
    groupLocation,
    groupMenu,
    groupVenueArea,
    brand,
    redirect,
    tag,
    category,
    post,
    postTag,
    event,
    partnership,
...
Here's my entire
schema.js
if that helps
I've already tried simplifying the
location
document to a single basic "Title" string field, to see if this error is related to an error in my document schema file, but still the error persists when creating new
location
documents.
Other documents (like
post
for blog posts) throw the same error, however most other document types in the project (e.g.
tag
) work as expected with no errors upon creation.
That doesn't look like it should be causing any problems. What does the location document schema look like?
Also, what version of the Studio are you running?
The
location
document type is rather large, so it's broken up into multiple JS files. Here's all the related files:
Here's a quick screencast of the error. Interesting (to me) that the JSON changes from
"_type": "*"
to
"_type": "location"
quickly after.
Versions from `package.json`:

    "@sanity/base": "^2.30.1",
    "@sanity/cli": "^2.30.2",
    "@sanity/color-input": "^2.30.1",
    "@sanity/components": "^2.14.0",
    "@sanity/core": "^2.30.2",
    "@sanity/dashboard": "^2.30.1",
    "@sanity/default-layout": "^2.30.1",
    "@sanity/default-login": "^2.30.1",
    "@sanity/desk-tool": "^2.30.1",
    "@sanity/production-preview": "^2.29.3",
    "@sanity/rich-date-input": "^2.0.9",
    "@sanity/vision": "^2.30.1",
We ended up figuring it out:
In the
desk/restaurants.js
file, I had failed to put a
schemaType('location')
for the children:

export const restaurantsMenu = S.listItem()
  .title('Restaurants')
  .id('restaurants')
  .child(
    S.list()
      .title('Restaurants')
      .items([
        S.listItem()
          .title('Locations')
          .child(
            S.documentTypeList('location').child((documentId) =>
              S.document()
                .documentId(documentId)
                .schemaType('location') // ← This was missing
                .views(standardViews)
            )
          )
          .icon(Storefront),
...
The new desk structure with
.schemaType('location')
on the
child()
element allows making new documents without error.
Odd how it worked before, though...
🤔
Thanks for your help
user M
AH, I'm so glad you were able to figure it out! I was just preparing to build out a version of this for testing, so your timing is perfect 😅 !

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.

Was this answer helpful?