Stack Trace: TypeError: Cannot Read Properties of Undefined (Reading 'Name')
Based on the error you're seeing and the solution found in the Sanity community, this TypeError: Cannot read properties of undefined (reading 'name') error that occurs specifically when creating new documents (but not when opening existing ones) is typically caused by outdated or incompatible Structure Builder syntax or custom document actions with missing properties.
The error is happening in the resolveEnabledActions and resolveDocumentActions functions, which means there's an issue with how document actions are being configured in your Structure Builder setup.
The Solution
The person who originally posted this exact issue found that their Structure Builder syntax was out of date. After refactoring the structure builder configuration to use current syntax, the problem was resolved.
Troubleshooting Steps
1. Check for custom document actions: Look in your project for any custom document actions configuration. If document actions are defined but have a missing or undefined name property, this will cause the exact error you're seeing. Document actions should always have a name property defined.
2. Review your Structure Builder: If you're using Structure Builder (typically in a deskStructure.js or similar file), check for deprecated syntax patterns. Common issues include:
- Outdated
.views()configuration - Improperly configured document lists
- Missing or malformed action definitions
3. Temporarily remove Structure Builder: To isolate the issue, try commenting out the Structure Builder configuration in your sanity.config.js (or sanity.json for v2). If the error disappears, you know it's definitely a Structure Builder issue.
4. Standard Node.js troubleshooting: Delete node_modules, remove your lock file (package-lock.json or yarn.lock), and reinstall dependencies. Sometimes package version mismatches can cause these issues.
5. Check for custom schema types: Since the error persists even with minimal fields, verify that any custom types referenced in your schema (like figure, custom objects, or references) are properly defined and don't have their own action configurations that might be problematic.
Why This Happens
The key insight is that this error happens during document creation because that's when Sanity tries to determine which actions (publish, unpublish, delete, duplicate, etc.) should be available for the new document. It's encountering something with a missing name property in that resolution process.
Since existing documents open fine, the issue is specifically in how the Studio is trying to resolve available actions for a new document of this type. This strongly points to either custom document actions or Structure Builder configuration that's using outdated syntax or has a configuration error.
The most common fix is refactoring your Structure Builder to use current Sanity v3 syntax if you're on an older version, or checking any custom document actions to ensure they all have proper name properties defined. In inherited projects especially, it's worth checking if the syntax matches the version of Sanity Studio you're actually running.
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.