Partial split error on the allowed values in list_string field type

Created on 13 September 2022, over 2 years ago
Updated 12 September 2024, 3 months ago

Problem/Motivation

Imagine that you have a list_string field type created in your content type. When you add the field.storage configuration item as a partial split, it does not work well with the allowed_values list. This is because the allowed_values list in configuration existing in the list_string fields is a sequence without a uuid attribute.

So, the config_split code uses the key in order to identify each item and this confuses the config merging process.

Steps to reproduce

- Create a list_string field type with two allowed values: "Yes|Yes" and "No|No"
- Create a new config split and add the field.storage config item as a partial split
- Activate the split
- Modify the field configuration adding a new item "Maybe|Maybe"
- Export the configuration. You should have the config_split.patch file in the split folder. So far so good.
- Import the configuration. The new field's allowed values are "Maybe|Maybe" and "No|No"

Proposed resolution

Same strategy as config_split already does with sequences that have a UUID attribute. I propose to check if there is a 'value' attribute and use it as identifier in case it exists.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

🇪🇸Spain unstatu

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada adam-vessey PE, Canada

    In terms of other data/schema types, I suspect all of those `list_*` types provided by the core "options" modules would be similarly problematic, so in addition to `list_string`, also `list_integer` and `list_float`? That said, I've not (yet) verified them personally.

  • 🇬🇧United Kingdom longwave UK

    When upgrading from config_split 2.0.0-beta4 to 2.0.1 on a multisite install that has a list_string field with split config with differing key/value pairs, I was running into this error after exporting config and then trying to reimport:

    Unexpected error during import with operation update for field.storage.block_content.field_background_type: A list field "field_background_type" with existing data cannot have its keys changed.
    

    Adding the hook in #4 worked for me, exporting the config added config_split_sequence keys to the changes instead of trying to renumber all the keys, and imports/exports worked as expected from then on.

Production build 0.71.5 2024