symfony/translation · error · InvalidArgumentException

Supported formats are

Error message

Supported formats are "%s".

What it means

Format validation in XliffLintCommand::display(): the --format option was set to something other than 'txt', 'json' or 'github', and the match expression has no default branch, so producing the lint report is impossible. Note that 'github' is auto-selected in GitHub Actions environments, and the InvalidArgumentException names the supported formats in its message.

Solutions

  1. Run with one of --format=txt, --format=json or --format=github.
  2. Remove the explicit --format option to let the default (github in GitHub Actions, otherwise txt) apply.
  3. Check scripts/CI wrappers for a misspelled format value.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at Command/XliffLintCommand.php:165 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15). Data as JSON: /api/errors/039acecb40ffbe02. Report an issue: GitHub.

Appendix: source

Thrown at Command/XliffLintCommand.php:165

                'line' => $xmlError['line'],
                'column' => $xmlError['column'],
                'message' => $xmlError['message'],
            ];
        }

        libxml_clear_errors();
        libxml_use_internal_errors($internal);

        return ['file' => $file, 'valid' => !$errors, 'messages' => $errors];
    }

    private function display(SymfonyStyle $io, array $files): int
    {
        return match ($this->format) {
            'txt' => $this->displayTxt($io, $files),
            'json' => $this->displayJson($io, $files),
            'github' => $this->displayTxt($io, $files, true),
            default => throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
        };
    }

    private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGithubAnnotations = false): int
    {
        $countFiles = \count($filesInfo);
        $erroredFiles = 0;
        $githubReporter = $errorAsGithubAnnotations ? new GithubActionReporter($io) : null;

        foreach ($filesInfo as $info) {
            if ($info['valid'] && $this->displayCorrectFiles) {
                $io->comment('<info>OK</info>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
            } elseif (!$info['valid']) {
                ++$erroredFiles;
                $io->text('<error> ERROR </error>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
                $io->listing(array_map(static function ($error) use ($info, $githubReporter) {
                    // general document errors have a '-1' line number
                    $line = -1 === $error['line'] ? null : $error['line'];

View on GitHub (pinned to ae9e8a51bc)