The config key_store (entity queries) can't handle long key values

Created on 21 August 2025, 2 days ago

Problem/Motivation

Found via a webform issue. 🐛 Out of memory because of too large library definitions Needs work .

Webform has a feature where you can add CSS or JavaScript in the webform config entity.

I tried to add an entity query to filter webforms by whether they have anything in those keys prior to them being loaded. One of webform's test modules has a long string in that key.

The way that the config entity key_store collection works is that the collection is the config entity type, the key value is the config key + value together (which has to fit in a 128 varchar), and the value is the config entity ID.

With that MR, running tests ends up with the following failure:

    Webform Cards Toggle Java Script (Drupal\Tests\webform_cards\FunctionalJavascript\WebformCardsToggleJavaScript)
     ✘ Toggle
       ┐
       ├ Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1: INSERT INTO "test96496449key_value" ("name", "collection", "value") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array
       ├ (                                                                        
       ├     [:db_insert_placeholder_0] => javascript:(function ($, Drupal, once) {
       ├                                                                          
       ├   'use strict';                                                          
       ├                                                                          
       ├   Drupal.behaviors.webformCardsTestJavaScript = {                        
       ├     attach(context) {                                                    
       ├       var $forms = $(context).is('form.webform-submission-form')         
       ├         ? $(context)                                                     
       ├         : $('form.webform-submission-form', context);                    
       ├                                                                          
       ├       $(once('webform-cards-test-javascript', $forms))                   
       ├         .on('webform_cards:change', function (event, $activeCard) {      
       ├           console.log('webform_cards:change');                           
       ├           console.log(event);                                            
       ├           console.log($activeCard);                                      
       ├         });                                                              
       ├     }                                                                    
       ├   };                                                                     
       ├                                                                          
       ├ })(jQuery, Drupal, once);                                                
       ├                                                                          
       ├     [:db_insert_placeholder_1] => config.entity.key_store.webform        
       ├     [:db_insert_placeholder_2] => a:1:{i:0;s:37:"webform.webform.test_cards_javascript";}
       ├ )                                                                        
       │

Steps to reproduce

Proposed resolution

One possible option would be to pre-truncate the string before it goes to the database. For the webform use case, we only need to know if the value is not-empty, not do an exact string comparison.

If that's not acceptable, then we should probably valid the length and throw a clear exception - however if so that seriously limits the options for optimizing the webform case.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

configuration entity system

Created by

🇬🇧United Kingdom catch

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