Error: Custom annotation types not found in Sanity schema definition

23 replies
Last updated: Nov 29, 2025
Hi again. I have come upon another error I'm not sure about. After adding this:

marks: {
 annotations: [
  {
   name: "link",
   type: "externalLink",
   title: "Ekstern lenke",
  },
  {
   name: "internalLink",
   type: "internalLink",
   title: "Intern lenke",
  },
 ],
}
to the block type in an


of: [{ type: "block" }]
I get this error:


Uncaught error
Could not resolve jsonType of undefined. No parent type found

Stack:

    at isJSONTypeOf (<http://localhost:3333/static/js/app.bundle.js:218462:11>)
    at <http://localhost:3333/static/js/app.bundle.js:218411:55>
    at Array.map (<anonymous>)
    at validateAnnotations (<http://localhost:3333/static/js/app.bundle.js:218399:22>)
    at validateMarks (<http://localhost:3333/static/js/app.bundle.js:218334:19>)
    at validateBlockType (<http://localhost:3333/static/js/app.bundle.js:218291:13>)
    at visitors.reduce._objectSpread._problems (<http://localhost:3333/static/js/app.bundle.js:217140:17>)
    at Array.reduce (<anonymous>)
    at <http://localhost:3333/static/js/app.bundle.js:217139:21>
    at <http://localhost:3333/static/js/app.bundle.js:217161:49>

(Your browsers Developer Tools may contain more info)
I've attempted to simplify the objects in annotations, but no matter what object i feed in, the end result is the same. Only way to stop getting it is to either not feed anything into annotations, or to use an inline object. But since my current project uses gatsby, inline objects aren't an option.
AI Update

The error you're encountering happens because when you reference annotation types by name (like type: "externalLink"), Sanity needs to find those type definitions in your schema, but they're not defined yet. The schema validation is looking for the actual type definitions but finding undefined.

Here's how to fix it:

Define Your Annotation Types First

You need to create the actual schema definitions for externalLink and internalLink as separate schema types before referencing them in your block configuration. Here's an example:

// In your schema files, define these as separate types:
export default {
  name: 'externalLink',
  type: 'object',
  title: 'External Link',
  fields: [
    {
      name: 'href',
      type: 'url',
      title: 'URL',
      validation: Rule => Rule.required()
    },
    {
      name: 'blank',
      type: 'boolean',
      title: 'Open in new tab',
      initialValue: true
    }
  ]
}
export default {
  name: 'internalLink',
  type: 'object',
  title: 'Internal Link',
  fields: [
    {
      name: 'reference',
      type: 'reference',
      title: 'Reference',
      to: [
        { type: 'page' }, // adjust to your document types
        { type: 'post' }
      ]
    }
  ]
}

Then make sure these types are included in your schema array when you create your Sanity schema.

Then Reference Them in Your Block

Once defined, your block configuration should work:

marks: {
  annotations: [
    {
      name: "link",
      type: "externalLink",
      title: "Ekstern lenke",
    },
    {
      name: "internalLink",
      type: "internalLink",
      title: "Intern lenke",
    },
  ],
}

The key issue is that Sanity's schema validation runs through all type references and tries to resolve them. When you use type: "externalLink", it looks for a schema type with name: "externalLink" but can't find it, resulting in the "Could not resolve jsonType of undefined" error during the validateAnnotations step.

You mentioned inline objects work but aren't an option with Gatsby - defining the types separately as shown above should resolve this while maintaining compatibility with your Gatsby setup. This is actually the recommended approach for custom annotations as it keeps your schema organized and reusable.

Show original thread
23 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.

Was this answer helpful?