Debugging an error with initial value templates in Sanity Studio
This is indeed an exotic error! "Target value is neither indexable or an object" is not commonly documented, but the fact that it only affects one colleague is a big clue - this typically points to a local environment or cache issue.
Most Likely Causes
1. Schema/Cache Mismatch (Most Common) Since it's colleague-specific, they likely have stale cached data. The reference field is trying to read a document structure that doesn't match what it expects.
Have your colleague try:
- Delete the
.sanityfolder in your project directory - Hard refresh the browser (Ctrl+Shift+R / Cmd+Shift+R)
- Clear browser cache and localStorage for the Studio URL
- Run
sanity schema deployto sync schemas - Try opening Studio in an incognito/private window
2. Corrupted Document Data
That specific page might have malformed data. This happens when schemas change but documents aren't migrated, or if there's a null/unexpected value where the reference preview expects an object.
To investigate, use Vision (GROQ query tool):
*[_id == "problematic-page-id"][0]Look for any fields with unexpected values, missing required fields, or null where objects should be.
3. Custom Preview Configuration Issue
If your page schema has a custom preview configuration, it might be trying to access nested fields that don't exist on that specific document:
preview: {
select: {
title: 'title',
subtitle: 'someField.nestedProperty' // If this path is broken
}
}4. Dependency Version Mismatch Your colleague might have different package versions:
- Have them delete
node_modulesand runnpm installfresh - Verify they're on the same Node.js version as you
- Check for any local Studio configuration overrides
Quick Fix Sequence
- Close Studio completely
- Delete browser cache/localStorage
- Delete
node_modulesand reinstall - Restart dev server
- Open in incognito window
If none of this works, the document data itself is likely the culprit - you'll need to inspect it in Vision and potentially migrate/fix the malformed fields on that specific page.
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.