Problem/Motivation

I have a SDC component with the following in the definition (MY_COMPONENT.component.yml):

libraryOverrides:
  header: true

This triggered the following error after updating to Drupal 11.4.0:

Drupal\Core\Render\Component\Exception\InvalidComponentException: In component MY_MODULE.MY_COMPONENT: [library] The property header is not defined and the definition does not allow additional properties in Drupal\Core\Theme\Component\ComponentValidator->validateDefinition() (line 153 of core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).

Steps to reproduce

  1. Create a component with the libraryOverrides.header property.
  2. Use the component on some page.
  3. Open the page.

Background

The header property is documented here: https://www.drupal.org/docs/develop/creating-modules/adding-assets-css-j...

Proposed resolution

I adjusted the schema for libraries by adding the following to property definitions:

"header": {
  "type": "boolean"
},

The relevant one seems to be under core/assets/schemas/v1/metadata-full.schema.json > properties/library/properties.
If that's correct, the error might apply to any library definition, not just components.

Tracing the definition, I started with "libraryOverrides", which is defined in core/assets/schemas/v1/metadata.schema.json. It references #/$defs/LibraryDefinition/, so I added the the above to its properties first, but it didn't fix the issue. I would still add it for consistency.

Remaining tasks

  1. Review the patch.
  2. Add a test for library/component schema.
  3. Clarify where the difference between "library" (metadata-full.schema.json) and "LibraryDefinition" (metadata.schema.json) is.

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

Corrected definition for header property in library schema .

CommentFileSizeAuthor
#2 3608197-2.patch896 byteslars.stiebenz

Issue fork drupal-3608197

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lars.stiebenz created an issue. See original summary.

lars.stiebenz’s picture

StatusFileSize
new896 bytes

lars.stiebenz’s picture

Issue summary: View changes
quietone’s picture

Version: 11.4.x-dev » main

Hi, Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.