Creating a CSS injector and saving it causes a WSoD on the site. None of the pages are anymore accessible, even if the CSS injector was set to be used on a specific content type, for example.
The logs show the following exception.
Exception: Invalid CSS asset type. in Drupal\Core\Asset\CssCollectionRenderer->render() (line 72 of core/lib/Drupal/Core/Asset/CssCollectionRenderer.php).
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries(Object, Array) (Line: 161)
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments(Object) (Line: 94)
Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor->processAttachments(Object) (Line: 45)
Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond(Object, 'kernel.response', Object)
call_user_func(Array, Object, 'kernel.response', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.response') (Line: 191)
Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 179)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 191)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 128)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 82)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 706)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce the issue
- On simplytest.me, select Drupal core 9.2.4 as main project, and asset_injector as additional project (under Advanced options)
- Visit /admin/config/development/asset-injector
- Click on CSS Injector
- On the next page, click on Add CSS Injector
- Enter Test for Label and the following CSS style for Code
.formatted-text { font-size: 2em; } - On Conditions, clicks on a content type, for example Article
- Leave the other settings as they are
- Click on the Save button
- Once the page reload, it shows a WSOD

Issue fork asset_injector-3214979
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
avpadernoComment #3
xurizaemonI followed the steps to reproduce in the issue description and was unable to reproduce this issue.
Comment #4
avpadernoNo step to reproduce the error message is given. It's not even clear if this is a bug report or a support request.
At least, it should be necessary to see which CSS code has been entered in the module form.
Comment #5
avpadernoI reproduced it on simplytest.me, on Drupal 9. It was enough to enter valid CSS style and save. Unfortunately, I didn't limit the pages to which the CSS style was added, with the effect that I could not check the log for errors, but the site shown the classic The website encountered an error sentence.
Comment #6
avpadernoComment #7
avpadernoActually, it happens also when creating a JavaScript injector.
Comment #8
xurizaemonThat's interesting! The steps I followed were "When I create a CSS injector rule" per (I think?) the original issue description. You're right that the original steps to reproduce were incomplete. Thanks for reproducing.
I was able to successfully create a CSS and JS injector rule on a local pre-existing D9 (9.1.11) site + Asset Injector 8.x-2.7 when trying to reproduce, so that's interesting you're able to demonstrate this bug on simplytest.me!
I tried to do the same on simplytest.me (I'm considering this module for a project, so was checking out the issue queue when I saw the apparent duplicate issues). On simplytestme I got inconsistent results, but I didn't see the WSoD that you did. I was testing with Drupal 8.9.18 on Simplytest.me
The Tugboat environment is at https://stm61268e4a4fb41-gpgxpse51b6np6ufl9qrshhwmfah4ri7.tugboat.qa for the next 12H if you want to compare this against the one you saw WSoD in :) user/pass is per the defaults for Simplytest.me
Comment #9
avpadernoIt happens only with Drupal 9. That is the Drupal version reported in the original report, which contained the following sentence.
I apologize: In the tentative of cleaning up the IS, I forgot to add that in the Steps to reproduce.
Comment #10
xurizaemonAgree, seems like it is Drupal version related. A few more simplytest.me experiments:
- Drupal 8.9.18 on simplytest.me - works as expected
- Drupal 9.1.12 on simplytest.me - WSoD
- Drupal 9.2.4 on simplytest.me - WSoD
And yet Asset Injector 8.x-2.7 + Drupal 9.1.11 locally worked fine for me, which feels inconsistent - but it was on a pre-existing local site, so IMO is best noted then ignored from the sample - just watch out in case this bug doesn't *always* manifest on 9.x environments I guess.
Having confirmed against 9.1.12 and 9.2.4 using simplytest.me, I'll leave this alone. I only meant to step in to reduce the duplicates, but I'm happy we seem to have identified a legit bug!
Comment #11
xurizaemonConsider #3169757: WSOD and Uncaught PHP Exception Exception: "Only file CSS assets can be optimized." also? Both mention the asset type being unset.
Comment #12
avpadernoI cannot understand where exactly the module causes this issue, but the code that throws the exception shown in the IS is the following one (in
CssCollectionRenderer::render()).Apparently, the code is expecting just
'file'or'external'as CSS asset type, but it receives another value.Comment #13
avpadernoI tried again on simplytest.me, still with Drupal 9.2.4, but this time I uninstalled the BigPipe module before adding any CSS injector. It worked: I was able to save the CSS injector without getting any WSoD.
I take it's a conflict with the BigPipe module.
Comment #16
s_leu commentedI also ran into this in combination with the workspaces module. The reason for the fatal error due to the missing asset type is in asset_injector_css_alter(), that code writes a group into the $css array, even if there is no index of asset_injector in the array. So that will cause a new index with just a value of ['group' => 999], which in turn leads to the fatal error.
I'm not 100% sure if this fix is causing any other sideeffects, but so far it worked for me.
Comment #17
pookmish commentedThe merge request in #15 makes sense why the error could be occurring. I was able to reproduce the error by adding
$css['foo']['group'] = 999;to the hook_css_alter. The result is exactly as everyone has described. I've merged the change and I'll push out a new release. I think we can call this fixed finally.Comment #19
nbutun commentedMany thanks to all the commenters.