Problem/Motivation

When translating a page, the Layout builder copy widget throws an error
AssertionError: Cannot load the "paragraph" entity with NULL ID. in assert() (line 262 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

The reason when we drilled down on this, was that the hook entity_duplicate (introduced via https://www.drupal.org/project/paragraphs/issues/3495373), the $duplicate->getFields() modifies the duplicate passed into it, and adds all the fields from fieldDefinition to itself.

Steps to reproduce

Using the module Layout Builder Asymmetric Translation, create a page with blocks in it, specifically a paragraph block
Add new translation.
error occurs.

Proposed resolution

Instead of iterating over getFields(), instead, iterate over fieldDefinitions().

Remaining tasks

Review patch.

CommentFileSizeAuthor
#3 3534829-1.patch849 bytesbingol@ciandt.com

Issue fork paragraphs-3534829

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

atowl created an issue. See original summary.

bingol@ciandt.com’s picture

StatusFileSize
new849 bytes
berdir’s picture

Status: Active » Needs work
Issue tags: -entity, -duplicate

This change doesn't make sense, it's broken and a fatal error on foreach ($fields as item)

atowl’s picture

Hi @berdir,

Could you be a bit more specific? So i could look further?

The only test it seems to be failing is the phpunit, and thats currently failing on 8.x-1.x branch as well.

Thanks

finex’s picture

Hi, I'm also using Layout Builder AT and I'm experiencing the same error when translating nodes with Layout Builder, but only when a block contains a paragraph field.

I haven't debugged as deeply as @atowl, but I can confirm that the duplicated object is indeed suspicious.

The patch works fine for me. Now, when I try to translate a node with Layout Builder and a block containing a paragraph field, it works as expected.

What's very strange is that if I take the same codebase and use a clean D11 installation with just a couple of languages and a simple block + paragraph setup, I can't reproduce the error. The configuration looks the same. I've also cleaned all the data tables, but maybe I'm missing something.

apotek’s picture

Status: Needs work » Reviewed & tested by the community

We have been using this fix in production since Aug 2025. Before we applied this patch, we would get the following error when attempting to translate a node that contained a paragraph block in Layout Builder:

AssertionError: Cannot load the "paragraph" entity with NULL ID. in assert() (line 262 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
Drupal\Core\Entity\EntityStorageBase->load() (Line: 343)
Drupal\layout_builder_at\Plugin\Field\FieldWidget\LayoutBuilderCopyWidget->cloneEntity() (Line: 254)

With the patch applied, we are able to translate the node.