Problem/Motivation
Today I found out that I had the following structure in a *.libraries.yml.
global-styling:
css:
component:
assets/css/components/mycomponent1/mycomponent1.css:
assets/css/components/mycomponent2/mycomponent2.css: {}
In Drupal 11, that missing {} translates to a bricked site. I could not even login using drush uli.
The error message that was displayed was
AssertionError: CSS must be nested under a category. See https://www.drupal.org/node/2274843. in assert() (line 128 of /var/www/html/docroot/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php)..
The returns in LibraryDiscoveryParser::validateCssLibrary should be updated so that is_array is not the only test.
Steps to reproduce
- Open a library and remove the
{}. - Site is now bricked
Proposed resolution
The current messages implies that a libray is missing one of the 5 SMACSS keywords. The message does not state what the actual issue is; the yml is malformed.
Remaining tasks
TBD
User interface changes
TBD
Introduced terminology
TBD
API changes
TBD
Data model changes
TBD
Release notes snippet
TBD
Issue fork drupal-3634418
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
leandro713 commentedliking to work on this
Comment #4
leandro713 commentedI’ve opened an MR that improves the assertion message when a CSS library entry is missing its
{}options array, and adds a regression test for this case. The targeted test and the fullLibraryDiscoveryParserTestclass pass.Comment #5
smustgrave commentedVery nice work. I really have no objection to the change, think it's a nice improvement.
Comment #6
damienmckenna+1 for this improvement - simply bugs in library definitions are a common mistake, having a little help would be a great improvement for developers.