{"record":{"id":"1083fbc2ad2e9d47","repo":"symfony/translation","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":"InvalidResourceException","httpStatus":null,"severity":"error","filePath":"Loader/FileLoader.php","lineNumber":27,"sourceCode":" * file that was distributed with this source code.\n */\n\nnamespace Symfony\\Component\\Translation\\Loader;\n\nuse Symfony\\Component\\Config\\Resource\\FileResource;\nuse Symfony\\Component\\Translation\\Exception\\InvalidResourceException;\nuse Symfony\\Component\\Translation\\Exception\\NotFoundResourceException;\nuse Symfony\\Component\\Translation\\MessageCatalogue;\n\n/**\n * @author Abdellatif Ait boudad <a.aitboudad@gmail.com>\n */\nabstract class FileLoader extends ArrayLoader\n{\n    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue\n    {\n        if (!stream_is_local($resource)) {\n            throw new InvalidResourceException(\\sprintf('This is not a local file \"%s\".', $resource));\n        }\n\n        if (!file_exists($resource)) {\n            throw new NotFoundResourceException(\\sprintf('File \"%s\" not found.', $resource));\n        }\n\n        $messages = $this->loadResource($resource);\n\n        // empty resource\n        $messages ??= [];\n\n        // not an array\n        if (!\\is_array($messages)) {\n            throw new InvalidResourceException(\\sprintf('Unable to load file \"%s\".', $resource));\n        }\n\n        $catalogue = parent::load($messages, $locale, $domain);\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/FileLoader.php#L9-L45","documentation":"FileLoader::load() checks stream_is_local($resource) before doing anything; if the resource is not a local filesystem path/stream it throws InvalidResourceException. The translation file loaders only support local files, not remote URLs or non-local stream wrappers.","triggerScenarios":"Calling FileLoader::load() (or any subclass: CsvFileLoader, YamlFileLoader, XliffFileLoader, etc.) with a resource such as 'http://example.com/messages.xlf', 'ftp://...', or another non-local stream wrapper.","commonSituations":"Trying to load translations from a remote URL or cloud-storage wrapper (s3://), configuring a loader with a URL instead of a local path, or passing a resource string fetched from config that points off-machine.","solutions":["Download the remote file locally first (copy(), file_get_contents()) and pass the local path to the loader.","Ensure the resource passed to load() is a local path or a local stream (stream_is_local() returns true).","If you must support remote resources, write a custom loader that fetches the content and delegates to loadResource() with a temp file.","Check for accidental 'http://' or other wrappers in the configured translation resource path."],"exampleFix":"// before\n$loader->load('https://cdn.example.com/messages.en.xlf', 'en');\n// after\n$tmp = tempnam(sys_get_temp_dir(), 'xlf_');\nfile_put_contents($tmp, file_get_contents('https://cdn.example.com/messages.en.xlf'));\n$loader->load($tmp, 'en');","handlingStrategy":"validation","validationCode":"if (!stream_is_local($resource)) {\n    throw new \\InvalidArgumentException(\"Translation resource must be local: $resource\");\n}","typeGuard":"function isLocalResource(mixed $r): bool { return is_string($r) && stream_is_local($r); }","tryCatchPattern":"try {\n    $catalogue = $loader->load($resource, $locale);\n} catch (Symfony\\Component\\Translation\\Exception\\InvalidResourceException $e) {\n    throw new \\LogicException('Only local translation files are supported: '.$e->getMessage(), 0, $e);\n}","preventionTips":["Never pass URLs or remote stream wrappers to file loaders.","Document that translation loaders accept local paths only.","Validate configured resource paths at container compile/boot time.","Download remote resources to a local cache before loading."],"tags":["file-loader","translation","invalid-resource","stream"],"backgroundTag":"invalid-argument-value","analyzedSha":"ae9e8a51bc29780d63c7f9efd6005d7c875e100b","analyzedAt":"2026-09-15T22:29:15.305Z","contentChangedAt":"2026-09-15T22:29:15.305Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}