Problem/Motivation
This is a follow-up on #3416700: Handle invalid compressed ajax_page_state more gracefully for the following improvements:
- Allow !== 0
/'s in the library name - Include information about the library that caused the BadRequestHttpException to make it easier to find the root cause as site administrator
- Improve the exception message to be clearer about what's changed and wrong
See related issues, e.g. https://www.drupal.org/project/asset_injector/issues/3444733#comment-155...
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3445072
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 #3
anybodyComment #4
anybodyImplemented the suggestion from @longwave (from #3416700: Handle invalid compressed ajax_page_state more gracefully) in the MR and added some comments.
I can't go into details about the if clause and the message, as I don't really understand what it really does and what this can be caused by.
So I don't know what exactly we can tell in the Exception or not.
Comment #5
catchA library has to be in the format
foo/bar, so this is just detecting if someone putssomerandomstringthatisnotalibraryin the query parameter somewhere. We just overlooked that people apparently usefoo/bar/bazsometimes, which is unexpected but possibly not wrong (or even if it's wrong worked until we broke it/So something like
Check that libraries are in the correct formatshould be fine I think?Comment #7
longwaveUpdated the comment and exception message to be more useful.
Comment #8
anybodyThanks @longwave, RTBC from my side, this clearly points out what happens. Perhaps @catch should sign this off, then this is ready to go?
Comment #9
longwaveSlightly surprised PHPStan did not pick up the invalid use of formatting on commit, but oh well, the tests caught it.
Comment #13
catchMuch better. Committed/pushed to 11.x and cherry-picked to 10.4.x/10.3.x/10.2.x, thanks!
Comment #17
thejimbirch commentedI ran into this on a 10.2.6 site. This was merged into 10.2.x a few days after that was released. So if you run into this until 10.2.7 comes out...
I patched drupal/core using a diff of the merge. The file URL for that is:
https://git.drupalcode.org/project/drupal/-/commit/81671bc5b9df29774a774...
Hope that helps.
The error message was:
Symfony\Component\HttpKernel\Exception\BadRequestHttpException: The libraries to include are encoded incorrectly. in Drupal\system\Controller\AssetControllerBase->Drupal\system\Controller\{closure}() (line 168 of /code/web/core/modules/system/src/Controller/AssetControllerBase.php).We were getting 400 errors on the JS files causing Admin Toolbar to print without styles.
Thanks for the issue and the fix! This was a squirrely one!
Adding this patch fixed the problem. Never could identify which library had an issue, or if there was a real issue.
Comment #18
shawn dearmond commentedWe ran into this yesterday on a 10.2.6 site. In our case, it was the Decoupled Blocks module.
#3447501: Drupal 10.2.6 causes libraries to fail