{"record":{"id":"1870479edbf0e152","repo":"getgrav/grav","slug":"the-middleware-is-not-a-valid-s-and-is-not-passed","errorCode":null,"errorMessage":"The middleware is not a valid %s and is not passed in the Container","messagePattern":"The middleware is not a valid (.+?) and is not passed in the Container","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":500,"severity":"error","filePath":"system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php","lineNumber":54,"sourceCode":"    /**\n     * {@inheritdoc}\n     * @throws InvalidArgumentException\n     */\n    public function handle(ServerRequestInterface $request): ResponseInterface\n    {\n        $middleware = array_shift($this->middleware);\n\n        // Use default callable if there is no middleware.\n        if ($middleware === null) {\n            return call_user_func($this->handler, $request);\n        }\n\n        if ($middleware instanceof MiddlewareInterface) {\n            return $middleware->process($request, clone $this);\n        }\n\n        if (null === $this->container || !$this->container->has($middleware)) {\n            throw new InvalidArgumentException(\n                sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class),\n                $middleware\n            );\n        }\n\n        array_unshift($this->middleware, $this->container->get($middleware));\n\n        return $this->handle($request);\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":65,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php#L36-L65","documentation":"Error \"The middleware is not a valid %s and is not passed in the Container\" thrown in getgrav/grav.","triggerScenarios":"Thrown at system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}