getgrav/grav · error · RuntimeException
Theme name not provided.
Error message
Theme name not provided.
What it means
Themes::get($name) looks up a theme's configuration and blueprints; it throws immediately when the name is empty (null, '', 0) because every later step (themes://{$name}/blueprints, themes://{$name}/{$name}.yaml) is meaningless without it. Note the asymmetry: a theme that is named but does not exist returns null; only a missing name throws.
Source
Thrown at system/src/Grav/Common/Themes.php:172
$list[$theme] = $result;
}
}
ksort($list, SORT_NATURAL | SORT_FLAG_CASE);
return $list;
}
/**
* Get theme configuration or throw exception if it cannot be found.
*
* @param string $name
* @return Data|null
* @throws RuntimeException
*/
public function get($name)
{
if (!$name) {
throw new RuntimeException('Theme name not provided.');
}
$blueprints = new Blueprints('themes://');
$blueprint = $blueprints->get("{$name}/blueprints");
// Load default configuration.
$file = CompiledYamlFile::instance("themes://{$name}/{$name}" . YAML_EXT);
// ensure this is a valid theme
if (!$file->exists()) {
return null;
}
// Find thumbnail.
$thumb = "themes://{$name}/thumbnail.jpg";
$path = $this->grav['locator']->findResource($thumb, false);
if ($path) {View on GitHub (pinned to 6040efed04)
Solutions
- Pass the real theme name, usually $grav['config']->get('system.pages.theme') or a literal like 'quark'
- Guard or default the value before calling: $name = trim((string) $name); if ($name !== '') { ... }
- If the value comes from config, fix the config key being read (e.g. system.pages.theme, not a nonexistent path)
Example fix
// before: config key typo yields null
$data = $themes->get($grav['config']->get('system.pages.theme.missing'));
// after
$name = $grav['config']->get('system.pages.theme') ?: 'quark';
$data = $name ? $themes->get($name) : null; Defensive patterns
Strategy: validation
Validate before calling
$name = is_string($name) ? trim($name) : '';
if ($name === '') {
// skip, default, or raise your own clearer error — do not call Themes::get()
$name = $grav['config']->get('system.pages.theme') ?: 'quark';
}
$data = $grav['themes']->get($name); // null means unknown-but-named theme Type guard
function isNonEmptyThemeName(mixed $name): bool
{
return is_string($name) && trim($name) !== '';
} Try / catch
try { $themes->get($name); } catch (RuntimeException $e) { // programming error: log with backtrace, do not use as control flow
$grav['debugger']->addException($e); return null; } Prevention
- Never feed unvalidated config keys or request data into Themes::get()
- Distinguish the two outcomes: empty name throws, unknown name returns null
- Default theme names explicitly in custom code
When it happens
Trigger: Calling $themes->get('') / ->get(null) / ->get(0) from custom code; passing an unset config key like $config->get('system.pages.theme.missing') (returns null); feeding a loop variable or request parameter that arrived empty; an admin/plugin enumerating themes where the iteration produced a blank entry.
Common situations: Plugins or Twig code that looks up a theme from unvalidated config or user input; refactors where a variable was renamed and now passes null; CLI scripts iterating theme folders with empty names.
Related errors
- {theme} theme could not be found
- Stream '{$type}' could not be initialized.
- Failed to save file '%s': %s
- Cannot save data, string required
- 500
AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17).
Data as JSON: /api/errors/73d349e05a885498.
Report an issue: GitHub.