Integrity constraint violation with paragraphs

Created on 3 June 2025, 22 days ago

Problem/Motivation

After creating a layout in a paragraph reference field and saving the node it works fine, but if I press the browser back button and resubmit the form it throws a mysql error for duplicate entry key.

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '900432cc-05da-4d74-9103-d20c913d0a3f' for key 'paragraphs_item.paragraph_field__uuid__value': INSERT INTO "paragraphs_item" ("revision_id", "type", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3);

Which makes sense.
A layout_paragraphs_storage_key is stored as a hidden input on the form, and is used by a tempstore to save or retrieve the layout_paragraph data, as the browser back button reloads the field values, so is that reloaded.

Steps to reproduce

  • create a node that uses the layout_paragraphs
  • click the browser back
  • save the node

you should see a drupal error message or it should duplicate the content, but you get the mysql error

Proposed resolution

add validation to catch this scenario (as the browser back scenario is probably not intentional behaviour of a content editor we should warn him on submission).

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇷🇴Romania andras_szilagyi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024