Hi,

As soon as I updated to 10.2.6, I started getting errors. I have been troubleshooting for hours, and it seems like when CSS is injected and aggregated (via core), it causes the following error:

Symfony\Component\HttpKernel\Exception\BadRequestHttpException: The libraries to include are encoded incorrectly. in Drupal\system\Controller\AssetControllerBase->Drupal\system\Controller\{closure}() (line 168 of /var/www/html/web/core/modules/system/src/Controller/AssetControllerBase.php).

The browser console also includes errors like:

Refused to apply style from <URL> because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

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

duckydan’s picture

Drupal Version 10.2.6
Apache 2.4.58
PHP 8.3.6
MariaDB 10.11.7
Memory limit 512M

duckydan’s picture

Issue summary: View changes
rajan kumar@2026’s picture

Assigned: Unassigned » rajan kumar@2026
rajan kumar@2026’s picture

Assigned: rajan kumar@2026 » Unassigned
mably’s picture

Same problem here :(

mably’s picture

Priority: Normal » Critical
mably’s picture

Looks like "/" are allowed only once in library names:

foreach ($libraries_to_check as $library) {
  if (substr_count($library, '/') !== 1) {
    throw new BadRequestHttpException('The libraries to include are encoded incorrectly.');
  }
}

And here is what I have this for $library in my case: asset_injector/css/fix_padding_top_exposition_slider

mably’s picture

MR created.

Chose "." as the replacement separator.

duckydan’s picture

Status: Active » Reviewed & tested by the community

Works great.

Thank you!

maxilein’s picture

Patch solved it for me as well. Thank you!

justcaldwell’s picture

That fixed it for us, too. Thanks @mably! 🙏

justcaldwell’s picture

Title: 10.2.6 Error » 10.2.6 Error - CSS preprocessing/aggregation fails
Issue summary: View changes

Tweaked the title and summary a bit to add some context.

justcaldwell’s picture

For reference, the changes that triggered this issue appear to have occurred in #3416700: Handle invalid compressed ajax_page_state more gracefully

anybody’s picture

Just ran into this after updating Drupal to 10.2.6.

I'm going to ping the maintainer as this is indeed critical and hard to find!

Furthermore we should open an issue in core for these things:

  1. Find out if the if clause is correct, makes sense and really needed: if (substr_count($library, '/') !== 1) {
  2. Add information about the failing library to the exception, otherwise the error is absolutely useless for site owners to find out what went wrong
  3. I think the error message is misleading. I wouldn't think of an "incorrect encoding" if there's an unexpected "/" in the library name??
anybody’s picture

Title: 10.2.6 Error - CSS preprocessing/aggregation fails » 10.2.6 Error - CSS preprocessing / aggregation fails, resulting in broken page / style
anybody’s picture

geek-merlin’s picture

Reviewing MR...

geek-merlin’s picture

Yes, this makes sense.
Adding attributions.

  • geek-merlin committed 8cb76d42 on 8.x-2.x authored by mably
    Issue #3444733 by mably, duckydan, Anybody, justcaldwell, geek-merlin,...
geek-merlin’s picture

Status: Reviewed & tested by the community » Fixed
anybody’s picture

Thank you very very much for your super quick reaction @geek-merlin! 🎉🚀

mably’s picture

Thank you @geek-merlin !

fonant’s picture

That was a nice fast fix! Thank you @geek-merlin!

avpaderno’s picture

edmoreta’s picture

StatusFileSize
new822 bytes

I confirmed this fixes the issue for Drupal core 10.2.x (10.2.6), patch applied on asset_injector v2.17.0 (no update for this module, so using patch instead)

duckydan’s picture

@edmoreta I think the most recent release (2.20) has this fix. I may be misunderstanding.

edmoreta’s picture

I haven't updated the asset_injector version, I need to stick to v2.17.0. I'm using a patch for that reason

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

trevorbradley’s picture

Note: This error was so bad on 2.19 (Complete CSS collapse) as we updated to 10.2.6, and the fix with 2.20 so complete, it's my opinion only but I'd strongly recommend flagging 2.19 as no longer supported.

We didn't catch in in our local and our dev environments because JS aggregation was only enabled on prod.