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

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

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

{
  type: 'object',
  fields: [
    // your fields
  ]
}

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:

import { at, defineMigration, setIfMissing } from 'sanity/migrate'

export default defineMigration({
  title: 'Add missing _type to anonymous inline objects',
  documentTypes: ['yourDocumentType'], // Replace with your actual document type
  migrate: {
    document(doc, context) {
      const arrayField = doc.yourArrayField as {
        title: string
        _key: string
        _type?: string
      }[]
      
      if (
        doc.yourArrayField &&
        arrayField.some((item) => item._type === undefined)
      ) {
        return arrayField
          .filter((item) => item._type === undefined)
          .map((item) => {
            return at(
              ['yourArrayField', { _key: item._key }, '_type'],
              setIfMissing('yourObjectName'), // Use the name you added to your schema
            )
          })
      }
    },
  },
})

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?

sanity.ioAll Systems Operational© Sanity 2026
Change site theme