getgrav/grav · error · InvalidArgumentException
The middleware is not a valid %s and is not passed in the Co
Error message
The middleware is not a valid %s and is not passed in the Container
What it means
Error "The middleware is not a valid %s and is not passed in the Container" thrown in getgrav/grav.
Source
Thrown at system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:54
/**
* {@inheritdoc}
* @throws InvalidArgumentException
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = array_shift($this->middleware);
// Use default callable if there is no middleware.
if ($middleware === null) {
return call_user_func($this->handler, $request);
}
if ($middleware instanceof MiddlewareInterface) {
return $middleware->process($request, clone $this);
}
if (null === $this->container || !$this->container->has($middleware)) {
throw new InvalidArgumentException(
sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class),
$middleware
);
}
array_unshift($this->middleware, $this->container->get($middleware));
return $this->handle($request);
}
}
View on GitHub (pinned to 6040efed04)
When it happens
Trigger: Thrown at system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17).
Data as JSON: /api/errors/1870479edbf0e152.
Report an issue: GitHub.