Why Notice: Undefined index: items in wp-includes/rest-api.php on line

I hope you are developing something interesting in WordPress with Gutenberg Block editor. If you are facing this warning message.
Generally this notice for Gutenberg array type attribute. When you register an attribute with an array type.

Notice: Undefined index: items in wp-includes/rest-api.php on line 1092.

I had similar trouble with it when I first started building blocks, so I think writing something about this. My block using post category list and it is saving multiple categories ids using multi-select control.

For fixing this issue. You just need to define “items” key and define what type of data you are trying to save into the database.
For arrays, you also have to pass in the type of the items in the array. Here’s an example from one of my blocks, which uses an array of int IDs:

register_block_type(
		'tb-blocks/tb-latest-posts-block',
		array(
			'attributes'      => array(
				'displayTabCategories' => array(
					'type' => 'array',
					'default' => '[]',
					'items' => array('type' => 'integer')
				),
			)
		)
	)

I hope this small code snippet helps you. Keep developing…