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

Created on 21 August 2025, 27 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