Error when trying to open a specific post in Sanity Studio, resolved with command line editing.
I feel your pain – this is a classic case of data getting into a state that breaks Studio's UI. The good news is you have several ways to fix this without nuking your entire dataset!
Quick Fix: Delete the Document via API
The fastest solution is to delete the problematic document using the Sanity CLI or client library. Here are your options:
Using the Sanity CLI:
sanity documents delete <document-id>You'll need the document ID, which you should be able to see in the URL or list view even if you can't open the document itself.
Using the JavaScript client:
import {createClient} from '@sanity/client'
const client = createClient({
projectId: 'your-project-id',
dataset: 'your-dataset',
token: 'your-token-with-write-access',
apiVersion: '2024-01-01',
useCdn: false
})
client.delete('document-id')
.then(() => console.log('Document deleted'))
.catch(err => console.error('Delete failed:', err))Alternative: Fix the Data with a Patch
If you want to salvage the document rather than delete it, you can use a patch operation to fix the broken field. Since you called an object where you should have called an array, you need to set that field to an empty array (or the correct array value):
client
.patch('document-id')
.set({ 'yourFieldName': [] }) // Replace with your actual field name
.commit()
.then(() => console.log('Document fixed'))
.catch(err => console.error('Patch failed:', err))If the field is nested, use dot notation like 'parentField.childField': []. The Patches documentation has more examples of targeting specific fields in complex documents.
Finding the Document ID
If you can see the document in the list view but can't open it, try:
- Hovering over it to see if the ID appears in a tooltip
- Looking at your browser's network tab when you click it – the failed request will show the document ID
- Using the Vision plugin (if installed) to query for recent documents of that type:
*[_type == "your-post-type"] | order(_updatedAt desc) [0...10]
If the Document is Referenced
If other documents reference this broken one and you're having trouble deleting it, the CLI delete command supports a --force parameter to delete documents even when they have strong references pointing to them. Be careful with this as it will break those references.
This error happens because Studio's ArrayInput component is trying to call .some() on a value that isn't an array – exactly what you suspected. Once you either delete the document or patch the field to be a proper array, you should be back in business!
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.