TypeError: Cannot Read Properties of Null (Reading 'jsonType')
This error typically happens when you have a schema field definition that's missing required properties or has a null/undefined value where Sanity expects a valid field configuration. The validateNonObjectFieldsProp function is trying to read the jsonType property from something that doesn't exist.
Here are the most common causes and how to fix them:
1. Missing type property
The most frequent cause is forgetting to include the type property in a field definition:
// ❌ This will cause the error
defineField({
name: 'title',
// missing type!
})
// ✅ This is correct
defineField({
name: 'title',
type: 'string'
})2. Null/undefined field in fields array
Check if you have any conditional logic that might be adding null or undefined to your fields array:
// ❌ This can cause issues
fields: [
defineField({ name: 'title', type: 'string' }),
someCondition && defineField({ name: 'optional', type: 'string' }), // might be false
]
// ✅ Filter out falsy values
fields: [
defineField({ name: 'title', type: 'string' }),
someCondition && defineField({ name: 'optional', type: 'string' }),
].filter(Boolean)3. Incorrect field reference or typo
Make sure all custom types you reference actually exist:
// ❌ If 'customType' doesn't exist in your schema
defineField({
name: 'myField',
type: 'customType' // typo or not defined
})4. Using deprecated syntax
If you're on Sanity Studio v3+, make sure you're using the modern schema syntax with defineField and defineType:
import { defineField, defineType } from 'sanity'
export default defineType({
name: 'post',
type: 'document',
fields: [
defineField({
name: 'title',
type: 'string'
})
]
})How to debug this
- Check your schema files systematically - Go through each schema file and verify every field has both
nameandtypeproperties - Look for dynamic field generation - If you're programmatically creating fields, add console.logs to see what's being generated
- Use the schema validation command - Run
sanity schema extractin your terminal to see if it can identify which schema has the issue - Check your imports - Make sure all imported schema types are properly exported and not undefined
The stack trace shows this is happening during schema traversal, so Sanity is trying to validate your schema structure when the Studio loads. The error means it encountered a field definition that doesn't have the expected structure, most commonly because the type property is missing or the entire field definition is null/undefined.
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.