symfony/var-dumper · error · InvalidArgumentException
Theme " " does not exist in class " ".
Error message
Theme "%s" does not exist in class "%s".
What it means
HtmlDumper::setTheme() validates the theme name against static::$themes (which defines 'default' and 'dark'). An unknown name throws InvalidArgumentException instead of silently keeping the current styles.
Solutions
- Use a built-in theme name: 'default' or 'dark'
- Check available themes in HtmlDumper::$themes for your installed version
- For custom themes, subclass HtmlDumper, add an entry to static::$themes, then call setTheme on the subclass
Example fix
// before
$dumper->setTheme('light');
// after
$dumper->setTheme('dark'); Defensive patterns
Strategy: validation
Validate before calling
$theme = $options['theme'] ?? 'default';
if (!isset(\Symfony\Component\VarDumper\Dumper\HtmlDumper::$themes[$theme])) {
throw new \InvalidArgumentException(sprintf('Unknown theme "%s"; available: %s', $theme, implode(', ', array_keys(\Symfony\Component\VarDumper\Dumper\HtmlDumper::$themes))));
} Type guard
function themeExists(string $theme, string $class = \Symfony\Component\VarDumper\Dumper\HtmlDumper::class): bool {
return isset($class::$themes[$theme]);
} Try / catch
try {
$dumper->setTheme($theme);
} catch (\InvalidArgumentException $e) {
$logger->warning($e->getMessage());
$dumper->setTheme('default');
} Prevention
- Validate user/config-supplied theme names against HtmlDumper::$themes before calling setTheme
- Remember only 'default' and 'dark' ship with var-dumper
- For custom themes, extend HtmlDumper and register the theme in static::$themes of the subclass
When it happens
Trigger: Calling `(new HtmlDumper())->setTheme('light')` or setTheme with any name not present in HtmlDumper::$themes; configuring a profiler/dump output with a mistyped theme option.
Common situations: Typos like 'dark-theme' or 'light'; assuming other themes exist; custom themes registered in a subclass but setTheme called on the base class.
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
AI-assisted analysis of symfony/var-dumper@e9d9cf5dcd (2026-09-14).
Data as JSON: /api/errors/a913c192201656e8.
Report an issue: GitHub.
Appendix: source
Thrown at Dumper/HtmlDumper.php:98
public function __construct($output = null, ?string $charset = null, int $flags = 0)
{
AbstractDumper::__construct($output, $charset, $flags);
$this->dumpId = 'sf-dump-'.mt_rand();
$this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->styles = static::$themes['dark'] ?? self::$themes['dark'];
}
public function setStyles(array $styles): void
{
$this->headerIsDumped = false;
$this->styles = $styles + $this->styles;
}
public function setTheme(string $themeName): void
{
if (!isset(static::$themes[$themeName])) {
throw new \InvalidArgumentException(\sprintf('Theme "%s" does not exist in class "%s".', $themeName, static::class));
}
$this->setStyles(static::$themes[$themeName]);
}
/**
* Configures display options.
*
* @param array $displayOptions A map of display options to customize the behavior
*/
public function setDisplayOptions(array $displayOptions): void
{
$this->headerIsDumped = false;
$this->displayOptions = $displayOptions + $this->displayOptions;
}
/**
* Sets an HTML header that will be dumped once in the output stream.View on GitHub (pinned to e9d9cf5dcd)