symfony/http-kernel · error · InvalidArgumentException
Invalid dump format: " ".
Error message
Invalid dump format: "%s".
What it means
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.
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.
Example fix
// before
$dumps = $collector->getDumps('text');
// after
$format = in_array($format, ['html', 'cli'], true) ? $format : 'html';
$dumps = $collector->getDumps($format); Defensive patterns
Strategy: validation
Validate before calling
if (!in_array($format, ['html', 'cli'], true)) {
throw new \InvalidArgumentException(sprintf('Format "%s" not supported; use html or cli.', $format));
} Type guard
/** @phpstan-assert 'html'|'cli' $format */
function isValidDumpFormat(mixed $format): bool
{
return \is_string($format) && in_array($format, ['html', 'cli'], true);
} Try / catch
try {
$dumps = $collector->getDumps($format);
} catch (\InvalidArgumentException $e) {
$dumps = $collector->getDumps(); // fall back to default format
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Message built by getControllerError(): e.g. Function
- Request payload contains invalid "form" data.
- Unsupported format: " ".
- Request payload contains invalid
- Request payload contains invalid
AI-assisted analysis of symfony/http-kernel@aa3a39d728 (2026-09-13).
Data as JSON: /api/errors/fc60b471186fd575.
Report an issue: GitHub.
Appendix: source
Thrown at DataCollector/DumpDataCollector.php:221
self::__construct($this->stopwatch ?? null, \is_string($fileLinkFormat) || $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : null, \is_string($charset) ? $charset : null);
}
public function getDumpsCount(): int
{
return $this->dataCount;
}
public function getDumps(string $format, int $maxDepthLimit = -1, int $maxItemsPerDepth = -1): array
{
$data = fopen('php://memory', 'r+');
if ('html' === $format) {
$dumper = new HtmlDumper($data, $this->charset);
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
$this->applyNonceTo($dumper);
} else {
throw new \InvalidArgumentException(\sprintf('Invalid dump format: "%s".', $format));
}
$dumps = [];
if (!$this->dataCount) {
return $this->data = [];
}
foreach ($this->data as $dump) {
$dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth));
$dump['data'] = stream_get_contents($data, -1, 0);
ftruncate($data, 0);
rewind($data);
$dumps[] = $dump;
}
return $dumps;
}
View on GitHub (pinned to aa3a39d728)