Drupal\sdc\Exception\InvalidComponentException: [type] NULL value found, but a string or an object is required. (status message)

Created on 8 April 2024, 9 months ago
Updated 2 May 2024, 8 months ago

Problem/Motivation

When using

{% embed 'radix:alert' with {
      type: types[type],
    } %}

(this is in the current default template for /templates/misc/status-messages.html.twig)

the following error is logged:

Drupal\sdc\Exception\InvalidComponentException: [type] NULL value found, but a string or an object is required. This may be because the property is empty instead of having data present. If possible fix the source data, use the |default() twig filter, or update the schema to allow multiple types./n[type] Does not have a value in the enumeration ["primary","secondary","success","danger","warning","info","light","dark"] in Drupal\sdc\Component\ComponentValidator->validateProps() (line 205 of /var/www/html/web/core/modules/sdc/src/Component/ComponentValidator.php)

Steps to reproduce

Call:

{% embed 'radix:alert' with {
      type: types[type],
    } %}

From a template.

Proposed resolution

I did this - However I wonder if we also need to address light/dark - am guessing this was added for 5.3 colour modes ?

{% embed 'radix:alert' with {
type: types[type]|default('info'),
} %}

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

🇬🇧United Kingdom martin@manarock.co.uk

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

Comments & Activities

Production build 0.71.5 2024