{"record":{"id":"25ab251d05a2f94e","repo":"symfony/routing","slug":"file-s-not-found","errorCode":null,"errorMessage":"File \"%s\" not found.","messagePattern":"File \"(.+?)\" not found\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Loader/YamlFileLoader.php","lineNumber":49,"sourceCode":"        parseRoute as doParseRoute;\n        validate as doValidate;\n    }\n\n    private YamlParser $yamlParser;\n\n    /**\n     * @throws \\InvalidArgumentException When a route can't be parsed because YAML is invalid\n     */\n    public function load(mixed $file, ?string $type = null): RouteCollection\n    {\n        $path = $this->locator->locate($file);\n\n        if (!stream_is_local($path)) {\n            throw new \\InvalidArgumentException(\\sprintf('This is not a local file \"%s\".', $path));\n        }\n\n        if (!file_exists($path)) {\n            throw new \\InvalidArgumentException(\\sprintf('File \"%s\" not found.', $path));\n        }\n\n        $this->yamlParser ??= new YamlParser();\n\n        try {\n            $parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);\n        } catch (ParseException $e) {\n            throw new \\InvalidArgumentException(\\sprintf('The file \"%s\" does not contain valid YAML: ', $path).$e->getMessage(), 0, $e);\n        }\n\n        $collection = new RouteCollection();\n        $collection->addResource(new FileResource($path));\n\n        // empty file\n        if (null === $parsedConfig) {\n            return $collection;\n        }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/YamlFileLoader.php#L31-L67","documentation":"YamlFileLoader::load() throws this InvalidArgumentException when the located routing file does not exist on disk. Note the locator usually runs first and throws FileLocatorFileNotFoundException for unresolvable paths; this check catches cases where the located path vanished or stream_is_local passed but file_exists fails.","triggerScenarios":"Passing a wrong or misspelled path to Router/YamlFileLoader::load(), referencing a file deleted at runtime, or an import in routes.yaml pointing to a nonexistent file with a resolvable-but-missing resolution.","commonSituations":"Typos in config/packages/routes paths; cache rebuilds after a file was removed; missing file in deployment artifact; case-sensitivity mismatch on Linux (Routes.yaml vs routes.yaml).","solutions":["Verify the file exists at the exact path: ls -la <path> (mind case sensitivity)","Fix the path in the router config / import statement","If the file is optional, guard with file_exists() or is_file() before loading","Ensure deployment includes the routes file in the artifact"],"exampleFix":"// before\n$router = new Router($loader, 'config/route.yml');\n// after\n$router = new Router($loader, 'config/routes.yaml');","handlingStrategy":"validation","validationCode":"if (!is_file($path)) { throw new \\RuntimeException(\"Routing file missing: $path\"); }","typeGuard":"null","tryCatchPattern":"try { $collection = $loader->load($file); } catch (\\InvalidArgumentException $e) { if (str_contains($e->getMessage(), 'not found')) { /* use default routes */ } throw $e; }","preventionTips":["Use %kernel.project_dir%/... or bundle-absolute @Bundle paths instead of relative guesses","Check file existence in CI for all configured route resources","Watch case sensitivity on Linux filesystems"],"tags":["routing","yaml","file-not-found","symfony"],"backgroundTag":"file-not-found","analyzedSha":"83fa223250b50f4f018c011e101c330e65ac63cc","analyzedAt":"2026-09-14T03:19:46.280Z","contentChangedAt":"2026-09-14T03:19:46.280Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}