[regression] Empty slots give incorrect validation message

Created on 13 May 2025, about 8 hours ago

Problem/Motivation

Since 🐛 SDC slots not being validated against json config schema Active landed in 11.1.7, empty slots, represented in Drupal by an empty array, give an error in SDCs when validated by ComponentValidator:

[slots.test-slot] Array value found, but an object is required

As soon as the slot contains any key-value pairs, this error goes away. This is because this method call converts associative arrays to objects, but leaves empty arrays as arrays:

    $definition_object = Validator::arrayToObjectRecursive($definition);

We already have some code to handle this for props but not slots:

    // If there are no props, force casting to object instead of array.
    if (($schema['properties'] ?? NULL) === []) {
      $schema['properties'] = new \stdClass();
    }

Steps to reproduce

Proposed resolution

Add similar defensive code for slots.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

single-directory components

Created by

🇬🇧United Kingdom longwave UK

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

Comments & Activities

Production build 0.71.5 2024