Inserting a very long string as a new term via node add form results in error

Created on 13 November 2023, about 1 year ago
Updated 14 December 2023, about 1 year ago

Problem/Motivation

Inserting a very long string as a new tag results in error;

Drupal\Core\Entity\EntityStorageException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1: INSERT INTO "taxonomy_term_field_data" ("tid", "revision_id", "vid", "langcode", "status", "name", "description__value", "description__format", "weight", "changed", "default_langcode", "revision_translation_affected", "content_translation_source", "content_translation_outdated", "content_translation_uid", "content_translation_created") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => 34 [:db_insert_placeholder_1] => 34 [:db_insert_placeholder_2] => tags [:db_insert_placeholder_3] => en [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 1245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678901245678901234567890124567890123456789012456789012345678 [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 1699876880 [:db_insert_placeholder_10] => 1 [:db_insert_placeholder_11] => 1 [:db_insert_placeholder_12] => und [:db_insert_placeholder_13] => 0 [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => 1699876880 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Steps to reproduce

Install Umami Demo, add an article with a new tag whose name is very long (probably the limit is 256 characters or longer).

Proposed resolution

Alert user of too long name already at the field widget, before submitting the form.

Remaining tasks

  • Add validation to the widget for string length < 256
  • Add inline error message when validation fails

User interface changes

Error message: "Names longer than 255 characters are not allowed in vocabulary name."

🐛 Bug report
Status

Closed: duplicate

Version

11.0 🔥

Component
Taxonomy 

Last updated 2 minutes ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇫🇮Finland simohell

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

Comments & Activities

Production build 0.71.5 2024