Skip to content

Block Undefined in Array of Blocks and Unable to Load Edit View for Document #10485

Closed
@58bits

Description

@58bits

Describe the Bug

A user working on a document that contained an array of blocks lost access to the document as a block became undefined (possibly while reordering blocks).

The problem was recently posted to Discord - https://discord.com/channels/967097582721572934/1102950643259424828/1326859801761939477 . Another user there (@JannikZed) also described having the same issue.

Attached is an image that shows the state of the field in the document - Object for block 6 (array index position 7) is now undefined.

Image

We then receive the following server error:

ERROR: Block with type "undefined" was found in block data, but no block with that type is defined in the config for field with schema path pages.content.

The user is then unable to edit the document - receiving a blank document edit screen - as shown below...

Image

Link to the code that reproduces this issue

https://github.com/payloadcms/payload

Reproduction Steps

Apologies for the link above - we've not immediately been able to reproduce this however it results in the loss of data, and was confirmed as an issue independently by a second user in Discord (@JannikZed) and so I felt this was serious enough to warrant the issue here.

Even if the issue can't be immediately resolved, I was wondering if it might be possible to more defensively code for block rendering, so that only the missing / undefined block show's as an error. The user would still be able to access the rest of the document - optionally removing the undefined block so that they can continue working on the document (despite the loss of data in the undefined block).

Hope this helps.

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Payload: v3.15.0
Node.js: v22.13.0 (LTS)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions