Error adding array to rich text and GraphQL deployment error
I've seen this error before! The TypeError: (value || []).some is not a function when adding an array to rich text (Portable Text) usually happens because of a schema configuration issue where your array field has corrupted data or an unexpected initial value.
Based on a community discussion about this exact error, here's what's likely happening and how to fix it:
Most Common Causes
1. Corrupted Document Data
The error happens when the ArrayInput component tries to call .some() on a value that isn't actually an array. This typically occurs when you accidentally saved a document with an object {} instead of an array [] for your Portable Text field.
2. Schema Configuration Issue
Sometimes an initialValue is set incorrectly:
// â WRONG - will cause the error
{
name: 'content',
type: 'array',
of: [{type: 'block'}],
initialValue: {} // Object instead of array!
}
// â
CORRECT
{
name: 'content',
type: 'array',
of: [{type: 'block'}],
initialValue: [] // or just omit it
}How to Fix It
Since you can't open the document in Studio to fix it, you'll need to edit it directly using the CLI:
Step 1: Get the document ID from the URL when you try to open it (even though it crashes). It'll look something like:
http://localhost:3333/desk/post;14f09fac-ddad-d4d4-9ed5-4b12346b3f90
Copy the ID part: 14f09fac-ddad-d4d4-9ed5-4b12346b3f90
Step 2: Open the document JSON in your terminal from your Studio directory:
sanity documents create --watch --replace --id 'YOUR_DOCUMENT_ID'If you want to use VS Code as your editor:
VISUAL=code sanity documents create --watch --replace --id 'YOUR_DOCUMENT_ID'Step 3: Look for the problematic array field in the JSON. It will likely look like:
"content": {}Change it to:
"content": []Step 4: Save and close the editor. The document will be updated automatically.
Important Note: If the document was published, you may also need to fix the draft version. The draft ID starts with drafts. - so if your document ID is abc123, you should also edit drafts.abc123 using the same command.
Prevention
After fixing the corrupted document, check your schema definition to ensure:
- No
initialValueis set to an object for array fields - Custom blocks are properly defined as object types if you're extending Portable Text
- You're not accidentally passing objects where arrays are expected in your code
This should get your Studio back up and running! The CLI approach has helped others with this exact same error message.
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.