The static_map process plugin does not work with periods in keys

Created on 8 June 2023, about 1 year ago
Updated 31 August 2023, 10 months ago

Problem/Motivation

This problem was originally reported as a bug in Drupal core: πŸ› Update documentation for handling dots in the static_map plugin Needs work . On that issue, we decided that the problem comes from storing migrations as config entities, which is supported by the migrate_plus module.

Thanks to #2293773: Field allowed values use dots in key names - not allowed in config β†’ , the Drupal configuration system does not allow periods (a.k.a. "dots") to appear in any configuration key. This causes problems when using the static_map process plugin to replace some.value.with.dots with something-else-without-dots.

Steps to reproduce

Create a custom migration with a perfectly reasonable static_map usage to translate source strings to allowed_values:

  field_cpu_bus_type:
    plugin: static_map
    source: BusType
    bypass: true
    map:
      'PCIe 3.0': pcie_3_0
      PCI: pci
...

The migration fails with

exception 'Drupal\Core\Config\ConfigValueException' with message 'PCIe 3.0 key contains a dot which is not supported.' in /var/www/example/docroot/core/lib/Drupal/Core/Config/ConfigBase.php:211

Proposed resolution

TBD

Here's one thought - permit map entries to be specified such that the map key is not a YAML key but rather a YAML value. E.g.:

  field_cpu_bus_type:
    plugin: static_map_plus
    source: BusType
    bypass: true
    map:
      -
        key: 'PCIe 3.0'
        value: pcie_3_0
      PCI: pci
...

In other words, add a new process plugin that extends static_map and pre-process the map key.

Remaining tasks

User interface changes

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

6.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

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

Comments & Activities

Production build 0.69.0 2024