{"record":{"id":"86c3dc941b255874","repo":"symfony/routing","slug":"this-is-not-a-local-file-s","errorCode":null,"errorMessage":"This is not a local file \"%s\".","messagePattern":"This is not a local file \"(.+?)\"\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Loader/YamlFileLoader.php","lineNumber":45,"sourceCode":"class YamlFileLoader extends FileLoader\n{\n    use ContentLoaderTrait {\n        parseImport as doParseImport;\n        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","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/YamlFileLoader.php#L27-L63","documentation":"YamlFileLoader::load() resolves the file via FileLocator then verifies it is a local stream (file:// or plain path). If stream_is_local() returns false — e.g. a remote stream wrapper like http:// or ftp:// — Symfony rejects it because YAML routing files must be readable as local files with resource tracking.","triggerScenarios":"Passing a URL (http://host/routes.yaml) or a non-local stream path to the router's resource config, or a FileLocator resolving to a stream wrapper that is not local.","commonSituations":"Configuring framework.router.resources (or imports in routes.yaml) with a remote URL; using a custom stream wrapper; containerized setups where a path accidentally becomes an s3:// or http:// stream.","solutions":["Use a local filesystem path (or bundle-relative @BundleName/Resources/config/routes.yaml) instead of a URL","Download/copy the remote YAML to a local path at deploy time and reference that path","Check the resolved path with stream_is_local($path) before configuring it as a routing resource"],"exampleFix":"// before\n$loader->load('https://config.example.com/routes.yaml');\n// after\n$loader->load('/etc/app/routes.yaml');","handlingStrategy":"validation","validationCode":"$path = $locator->locate($file); if (!stream_is_local($path)) { throw new \\InvalidArgumentException(\"Refusing non-local routing file: $path\"); }","typeGuard":"function isLocalFile(mixed $p): bool { try { return is_string($p) && stream_is_local($p); } catch (\\Throwable) { return false; } }","tryCatchPattern":"try { $loader->load($file); } catch (\\InvalidArgumentException $e) { if (str_contains($e->getMessage(), 'not a local file')) { /* fall back to local copy */ } throw $e; }","preventionTips":["Never point router resources at URLs or remote stream wrappers","Mirror remote route configs to local files in the deploy pipeline","Preflight stream_is_local() on dynamically computed resource paths"],"tags":["routing","yaml","file-loading","symfony"],"backgroundTag":"invalid-url","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"}