1

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

enter image description here

Can anyone help? Thanks

2 Answers 2

1

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 the routerList 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:

foreach ($this->_routerList as $router) {
    $actionInstance = $router->match($request); // Main debugging point!
    if ($actionInstance) {
        $request->setDispatched(true);
        $this->response->setNoCacheHeaders();
        if ($actionInstance instanceof \Magento\Framework\App\Action\AbstractAction) {
            $result = $actionInstance->dispatch($request);
        } else {
            $result = $actionInstance->execute();
        }
        // ...
    }
}

Seems like some custom router returns incorrect instance.

0

Please run the below commands. Let me know if it's works

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush
chmod 777 var/ generated/ pub/static/ pub/media/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.