TYPO3 Exception 1176558158

TYPO3 11.5.21 -03.01.2023

An argument "site" does not exist for this request.
Copied!

Situation

This happens when you call the following in an action of an Extbase controller:

$site =  $this->request->getArgument('site');
Copied!

Solution

You must retrieve the site configuration with getAttribute() not getArgument:

$site =  $this->request->getAttribute('site');
Copied!

TYPO3 12.4.3 - 24.07.23

Situation

This error was thrown in the \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder when calling it from a non-Extbase context

Solution

Pass the current request object to the UriBuilder:

$uri = $uriBuilder->reset()
        ->setRequest($this->getExtbaseRequest())
        ->setTargetPageUid(188)
        // ...
        ->build();
Copied!

See also URI builder (Extbase).