Routes pointing to Http4xxController are malformed

Created on 17 June 2015, about 10 years ago
Updated 26 June 2025, 11 days ago

Problem/Motivation

These routes have been wrong since they were added (in #2362517: Improve default 403/404 exception HTML subscriber: don't duplicate the page render pipeline, use the routing system β€” add system.403 and system.404 routes β†’ and #2472371: Exception shown on 401 Unauthorized β†’ .

The problem lies in \Drupal\Core\Controller\ControllerResolver::createController() It claims to want either service:method or class::method, note 1 vs 2 colons. From #2 πŸ› Routes pointing to Http4xxController are malformed Needs work .

Proposed resolution

Fix them

Remaining tasks

Find out why HEAD is passing, and write tests
Add exception messages.
A title change

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component

system.module

Created by

πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    This is difficult to update for 11.x. We now have ControllerResolver::getControllerFromDefinition instead of ::createController, and this offloads the work to CallableResolver::getCallableFromDefinition. I had a look at adding the logic exceptions to callable resolver, but we'd also have to inject the container. By the time we do the validation to see if it looks like a service but is actually a class, and vice versa, that's repeating a bunch of lookups that ClassResolver already does. It would possibly make more sense to add an extra param to ClassResolver::getInstanceFromDefinition to only return a service or only return a class. Then we could update CallableResolver to validate with that param. That is still expanding the scope of this beyond ControllerResolver, so perhaps the param needs to be set all the way back there.

    Or perhaps it doesn't matter and we should just allow this? We can "fix" the existing routes and carry on.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Do we know why there's no actual error here? Is it finding the class/method despite the wrong entry? Or are these ignored by the 404/403 handling and the route definitions are dead code?

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    The single colon is correct syntax for a method on a service. ClassResolver finds either a service or a class and returns an instance of the class. Then we check if the method exists on the class. So it's not dead code, it just "accidentally" works.

Production build 0.71.5 2024