Issue Bug New Stale Good first issue

#110159RTE YAML loader should support safe custom tags like !reset

Gabriel Kaufmann TYPOworx GmbH | NewMedia 07/06/26, 12:30 updated 07/09/26, 05:50

Description

TYPO3’s YAML loader currently rejects Symfony YAML custom tags such as `!reset`.

Example (here for extending RTE Config):

imports:
  - { resource: "EXT:rte_ckeditor/Configuration/RTE/Default.yaml" }

editor:
  config:
    heading:
      options: !reset
        - { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' }
        - { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' }
        - { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }

This fails with:

YamlParseException:
Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "!reset"

*Expected behavior*
RTE YAML presets should allow safe custom tags such as `!reset`, or TYPO3 should provide another documented way to replace imported list values.

*Proposed solution*
Enable safe custom tag parsing for RTE YAML presets, for example using:

Yaml::PARSE_CUSTOM_TAGS

or document an official alternative for resetting imported arrays/lists in RTE YAML configuration. But I think the goal should be to stay YAML and Symfony compatible here.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] RTE YAML loader should support safe custom tags like !reset Resolves: #110159 Releases: main

History 2

  1. Georg Ringer commented <span data-processor="relativetime" data-value="2026-07-08T19:18:51+00:00" > 07/08/26, 19:18 </span>

    ##  Why enabling `PARSE_CUSTOM_TAGS` is not enough
    
    If we only pass the flag, the following happens:
    
    1. `!reset [...]` no longer throws — but Symfony returns a `Symfony\Component\Yaml\Tag\TaggedValue` **object**, not an array.
    2. That object travels untouched through `processImports()` and `processPlaceholders()` and ends up **as an object** in the final configuration array.
    3. `replaceAndAppendScalarValuesRecursive()` cannot handle it: `array_is_list()` does not apply to an object, so no merge/reset logic triggers.
    4. The consumer (here: the ckeditor RTE configuration) receives a `TaggedValue` object where it expects a list of options → the configuration is broken.
    
    In other words, the flag only prevents the crash; it does **not** give the tag any meaning. `!reset` is also **not** a Symfony-defined tag — Symfony has no built-in semantics for it, so TYPO3 would have to define and implement the behaviour itself.
    
    ## What a correct implementation actually needs
    
    A proper solution requires three coordinated pieces:
    
    1. **Parser:** parse with `Yaml::parse($content, Yaml::PARSE_CUSTOM_TAGS)`.
    2. **Tag handling / unwrapping:** walk the parsed tree, detect `TaggedValue` nodes, interpret the `reset` tag (mark the affected list to be replaced), and **unwrap** the `TaggedValue` back into the plain value before it reaches any consumer. No `TaggedValue` object must ever leak into the final configuration.
    3. **Merge adjustment:** `replaceAndAppendScalarValuesRecursive()` must honour that marker — when the overriding side is flagged as `reset`, take its value directly instead of `array_merge()`. Ordering is the tricky part: `!reset` lives in the **importing** (child) file and must win over the **imported** (parent) list, and the marker has to survive/propagate through the recursive merge without corrupting sibling keys.
    
    Additionally, the semantics need to be defined for edge cases (associative arrays vs. lists, nested resets, whether an unknown tag should still throw), plus documentation and functional tests.
    
    ## Summary
    
    - Valid feature request, but **not** a one-line change.
    - Just setting `Yaml::PARSE_CUSTOM_TAGS` (as proposed) would be a regression: it swaps a clear exception for silently broken config (`TaggedValue` objects leaking into settings).
    - The value is in steps 2 + 3 — defining the tag semantics and integrating them into the existing append-based merge, while staying YAML/Symfony compatible (the `TaggedValue` route is the right one for that goal).
  2. Gabriel Kaufmann TYPOworx GmbH | NewMedia commented <span data-processor="relativetime" data-value="2026-07-09T05:50:46+00:00" > 07/09/26, 05:50 </span>

    Georg Ringer wrote in #note-1:

    Thanks for your investigations into this @just2b.