{"record":{"id":"c40f164cb575d491","repo":"symfony/translation","slug":"this-is-not-a-local-file-s-xlifffileloader","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/XliffFileLoader.php","lineNumber":40,"sourceCode":"use Symfony\\Component\\Translation\\MessageCatalogueInterface;\nuse Symfony\\Component\\Translation\\Util\\XliffUtils;\n\n/**\n * XliffFileLoader loads translations from XLIFF files.\n *\n * @author Fabien Potencier <fabien@symfony.com>\n */\nclass XliffFileLoader implements LoaderInterface\n{\n    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue\n    {\n        if (!class_exists(XmlUtils::class)) {\n            throw new RuntimeException('Loading translations from the Xliff format requires the Symfony Config component.');\n        }\n\n        if (!$this->isXmlString($resource)) {\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            if (!is_file($resource)) {\n                throw new InvalidResourceException(\\sprintf('This is neither a file nor an XLIFF string \"%s\".', $resource));\n            }\n        }\n\n        try {\n            if ($this->isXmlString($resource)) {\n                $dom = XmlUtils::parse($resource);\n            } else {\n                $dom = XmlUtils::loadFile($resource);\n            }\n        } catch (\\InvalidArgumentException|XmlParsingException|InvalidXmlException $e) {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/XliffFileLoader.php#L22-L58","documentation":"When the XLIFF resource is not an inline XML string, the loader checks stream_is_local(); remote streams (http://, ftp:// wrappers) are rejected with this InvalidResourceException because Symfony only loads translation files from local storage.","triggerScenarios":"Passing a URL or remote stream wrapper path as $resource to XliffFileLoader::load(), e.g. 'https://example.com/messages.en.xlf'.","commonSituations":"Developers pointing the translation loader at a CDN or remote translation service URL; configs built dynamically where the resource comes from an env var containing a URL.","solutions":["Download the XLIFF file to a local path first, then pass the local file path to load().","Use a stream wrapper that is local (e.g. copy to a temp file with copy() or file_get_contents and pass the XML string directly).","If passing XML content, ensure it is a string starting with '<?xml' so isXmlString() treats it as inline content."],"exampleFix":"// before\n$loader->load('https://cdn.example.com/messages.en.xlf', 'en');\n// after\n$xml = file_get_contents('https://cdn.example.com/messages.en.xlf');\n$loader->load($xml, 'en');","handlingStrategy":"validation","validationCode":"if (!is_string($resource) || !str_starts_with(ltrim($resource), '<?xml')) {\n    if (!stream_is_local($resource)) {\n        throw new \\InvalidArgumentException('Resource must be a local file or an XML string.');\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    $catalogue = $loader->load($resource, $locale);\n} catch (InvalidResourceException $e) {\n    if (str_contains($e->getMessage(), 'not a local file')) {\n        $resource = downloadToLocalTemp($resource);\n        $catalogue = $loader->load($resource, $locale);\n    }\n}","preventionTips":["Never pass URL stream wrappers as translation resources.","Resolve env-var-based resource paths at boot and assert they are local paths.","Fetch remote translations into a local cache directory before loading."],"tags":["php","xliff","remote-resource"],"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"}