Help articles

Error: Value of type "object" is not allowed in this array field

Error message: "Invalid clipboard item Value of type "object" is not allowed in this array field"

Missing Name Error for Inline Object Definitions

What this error means

This error occurs when your inline object definition is missing a name property. Even though these inline types are locally scoped and may not be reused elsewhere in your schema, Sanity still requires them to have a name.

Why names are required

Inline object types need names to support essential Sanity features, including:

  • Copy and paste functionality
  • GraphQL schema generation
  • TypeGen and schema extraction
  • Content migrations
  • Studio functionality

How to fix this issue

  • Add a name property to your inline object definition in your schema
  • Migrate existing content to match the updated schema structure

Example

Migration script example

After adding names to your inline objects, you'll need to migrate existing content to include the _type property. Here's an example migration script:

Key points for the migration:

  • Replace yourDocumentType with the document type containing the anonymous objects
  • Replace yourArrayField with the name of your array field
  • Replace yourObjectName with the name you assigned to your inline object
  • The migration finds items missing the _type property and adds it using setIfMissing()
  • Keep migration scopes as small as possible since you never know in the data what an inline object is, because it does not have a name

Was this page helpful?