A page with an invalid url should redirect to a page not found, but it throws an error
TypeError: Magento\Framework\App\FrontController::processRequest(): Argument #2 ($actionInstance) must be of type Magento\Framework\App\ActionInterface, Magento\Framework\Controller\Result\Redirect\Interceptor given, called in vendor\magento\framework\App\FrontController.php on line 147 and defined in vendor\magento\framework\App\FrontController.php:177
Can anyone help?
Thanks
Best Answer
Check any third-party modules that may influence router selection (using plugins or own router), which may result in an error. Try disabling all suspicious modules and check the result (don't forget to run
setup:di:compile
first).Analyze the
di.xml
files within these modules for any entries associated with therouterList
argument. This will provide insight into the sequence and any custom routers that might be active.Check routers list (and it's order) in the
Magento\Framework\App\FrontController::dispatch()
method (using xDebug or other debug method):Inside the
dispatch()
method, you will find a loop that goes through all the routers and tries to match the request to a specific router. This loop is where Magento tries each router in sequence until it finds one that can handle the request:Seems like some custom router returns incorrect instance.