Drupal\Core\Asset\Exception\InvalidLibraryFileException: Invalid library definition in modules/contrib/vito_cookie/vito_cookie.libraries.yml: Colons must be followed by a space or an indication

I encountered an error when upgrading to Drupal 10.3. The error occurs when a mymodule.libraries.yml definition had this as the css yaml:

global:
  version: 1.x
  css:
    theme:
      https://mysite.com/style.css: {type: external}
  dependencies:
    - core/drupal

This was the error i got:

The website encountered an unexpected error. Try again later.

Drupal\Core\Asset\Exception\InvalidLibraryFileException: Invalid library definition: Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}") at line 5 (near "https://mysite.com/style.css.css: { type:external }"). in Drupal\Core\Asset\LibraryDiscoveryParser->parseLibraryInfo() (line 401 of core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).

Solution

Drupal (or at least the yaml coding standards) now require a different way of adding extra variable types. Correct way:

global:
  version: 1.x
  css:
    theme:
      https://mysite.com/style.css: 
        type: external
  dependencies:
    - core/drupal

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!