{"record":{"id":"3a6ac33d29033eac","repo":"symfony/translation","slug":"the-file-dumper-needs-a-path-option","errorCode":null,"errorMessage":"The file dumper needs a path option.","messagePattern":"The file dumper needs a path option\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Dumper/FileDumper.php","lineNumber":44,"sourceCode":"abstract class FileDumper implements DumperInterface\n{\n    /**\n     * A template for the relative paths to files.\n     */\n    protected string $relativePathTemplate = '%domain%.%locale%.%extension%';\n\n    /**\n     * Sets the template for the relative paths to files.\n     */\n    public function setRelativePathTemplate(string $relativePathTemplate): void\n    {\n        $this->relativePathTemplate = $relativePathTemplate;\n    }\n\n    public function dump(MessageCatalogue $messages, array $options = []): void\n    {\n        if (!\\array_key_exists('path', $options)) {\n            throw new InvalidArgumentException('The file dumper needs a path option.');\n        }\n\n        // save a file for each domain\n        foreach ($messages->getDomains() as $domain) {\n            $fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());\n            if (!file_exists($fullpath)) {\n                $directory = \\dirname($fullpath);\n                if (!file_exists($directory) && !@mkdir($directory, 0o777, true)) {\n                    throw new RuntimeException(\\sprintf('Unable to create directory \"%s\".', $directory));\n                }\n            }\n\n            $intlDomain = $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX;\n            $intlMessages = $messages->all($intlDomain);\n\n            if ($intlMessages) {\n                $intlPath = $options['path'].'/'.$this->getRelativePath($intlDomain, $messages->getLocale());\n                file_put_contents($intlPath, $this->formatCatalogue($messages, $intlDomain, $options));","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Dumper/FileDumper.php#L26-L62","documentation":"Thrown by FileDumper::dump when the $options array does not contain the required 'path' key specifying where translation files should be written. All file-based dumpers (Yaml, Xliff, Po, etc.) inherit this requirement.","triggerScenarios":"Calling `$dumper->dump($catalogue, $options)` without 'path' in $options, or using translation:dump/console commands with dumping configuration missing the output path.","commonSituations":"Programmatic dumping of catalogues (e.g. exporting translations in a script) where the options array was built conditionally and 'path' got omitted; misconfigured custom dumper services.","solutions":["Pass `['path' => '/output/dir']` in the options array of dump()","For the console command, ensure translation dump output path is configured/passed correctly","Check any wrapper code that strips or filters options before calling dump()"],"exampleFix":"// before\n$dumper->dump($catalogue, ['format' => 'yml']);\n// after\n$dumper->dump($catalogue, ['path' => '%kernel.project_dir%/translations', 'format' => 'yml']);","handlingStrategy":"validation","validationCode":"if (!isset($options['path'])) { throw new \\LogicException('dump() requires the \"path\" option.'); } $dumper->dump($catalogue, $options);","typeGuard":null,"tryCatchPattern":"try { $dumper->dump($catalogue, $options); } catch (InvalidArgumentException $e) { if (str_contains($e->getMessage(), 'path option')) { // supply path and retry } }","preventionTips":["Always build dump options through a helper that sets 'path' with a default","Never spread user-supplied option arrays straight into dump() without merging defaults","Add a unit test asserting dump options include 'path'"],"tags":["symfony","translation","dumper","missing-option"],"backgroundTag":"missing-required-option","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"}