{"record":{"id":"fc60b471186fd575","repo":"symfony/http-kernel","slug":"invalid-dump-format-s","errorCode":null,"errorMessage":"Invalid dump format: \"%s\".","messagePattern":"Invalid dump format: \"(.+?)\"\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"DataCollector/DumpDataCollector.php","lineNumber":221,"sourceCode":"\n        self::__construct($this->stopwatch ?? null, \\is_string($fileLinkFormat) || $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : null, \\is_string($charset) ? $charset : null);\n    }\n\n    public function getDumpsCount(): int\n    {\n        return $this->dataCount;\n    }\n\n    public function getDumps(string $format, int $maxDepthLimit = -1, int $maxItemsPerDepth = -1): array\n    {\n        $data = fopen('php://memory', 'r+');\n\n        if ('html' === $format) {\n            $dumper = new HtmlDumper($data, $this->charset);\n            $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);\n            $this->applyNonceTo($dumper);\n        } else {\n            throw new \\InvalidArgumentException(\\sprintf('Invalid dump format: \"%s\".', $format));\n        }\n        $dumps = [];\n\n        if (!$this->dataCount) {\n            return $this->data = [];\n        }\n\n        foreach ($this->data as $dump) {\n            $dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth));\n            $dump['data'] = stream_get_contents($data, -1, 0);\n            ftruncate($data, 0);\n            rewind($data);\n            $dumps[] = $dump;\n        }\n\n        return $dumps;\n    }\n","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/DataCollector/DumpDataCollector.php#L203-L239","documentation":"DumpDataCollector::getDumps() only supports two output formats: 'html' (via HtmlDumper) and a compact array format (via DataDumperInterface fallback). Any other $format string triggers InvalidArgumentException. This is a programming error in the caller, not a runtime condition — the format is fixed by the class contract.","triggerScenarios":"Calling $collector->getDumps($format, ...) with a format other than 'html' or the accepted compact/default (e.g. 'text', 'cli', 'json'); passing a user-supplied format string straight through to the collector.","commonSituations":"Custom debug tooling built on the Web Profiler's DumpDataCollector; script/CLI utilities dumping collected var_dumps output; copy-pasting a format name from another dumper API.","solutions":["Pass 'html' or omit the argument (default) when calling getDumps().","Check the collector's accepted formats in DumpDataCollector.php and normalize input before calling (e.g. in_array check).","If you need plain text, use the DataDumperInterface path (default format) instead of inventing a format string."],"exampleFix":"// before\n$dumps = $collector->getDumps('text');\n// after\n$format = in_array($format, ['html', 'cli'], true) ? $format : 'html';\n$dumps = $collector->getDumps($format);","handlingStrategy":"validation","validationCode":"if (!in_array($format, ['html', 'cli'], true)) {\n    throw new \\InvalidArgumentException(sprintf('Format \"%s\" not supported; use html or cli.', $format));\n}","typeGuard":"/** @phpstan-assert 'html'|'cli' $format */\nfunction isValidDumpFormat(mixed $format): bool\n{\n    return \\is_string($format) && in_array($format, ['html', 'cli'], true);\n}","tryCatchPattern":"try {\n    $dumps = $collector->getDumps($format);\n} catch (\\InvalidArgumentException $e) {\n    $dumps = $collector->getDumps(); // fall back to default format\n}","preventionTips":["Hardcode 'html' or the default argument; never pass user input as $format.","Consult DumpDataCollector's source to confirm which formats the installed Symfony version accepts.","Add a unit test covering every format string your tooling passes to getDumps().","Use a whitelist enum/constant instead of free-form strings for dump formats."],"tags":["symfony","debug","var-dumper","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}