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
- Create a component with the libraryOverrides.header property.
- Use the component on some page.
- 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
- Review the patch.
- Add a test for library/component schema.
- 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 .
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3608197-2.patch | 896 bytes | lars.stiebenz |
Issue fork drupal-3608197
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
Comment #2
lars.stiebenz commentedComment #4
lars.stiebenz commentedComment #5
quietone commentedHi, 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.