{"record":{"id":"73d349e05a885498","repo":"getgrav/grav","slug":"theme-name-not-provided","errorCode":null,"errorMessage":"Theme name not provided.","messagePattern":"Theme name not provided\\.","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Common/Themes.php","lineNumber":172,"sourceCode":"                $list[$theme] = $result;\n            }\n        }\n        ksort($list, SORT_NATURAL | SORT_FLAG_CASE);\n\n        return $list;\n    }\n\n    /**\n     * Get theme configuration or throw exception if it cannot be found.\n     *\n     * @param  string $name\n     * @return Data|null\n     * @throws RuntimeException\n     */\n    public function get($name)\n    {\n        if (!$name) {\n            throw new RuntimeException('Theme name not provided.');\n        }\n\n        $blueprints = new Blueprints('themes://');\n        $blueprint = $blueprints->get(\"{$name}/blueprints\");\n\n        // Load default configuration.\n        $file = CompiledYamlFile::instance(\"themes://{$name}/{$name}\" . YAML_EXT);\n\n        // ensure this is a valid theme\n        if (!$file->exists()) {\n            return null;\n        }\n\n        // Find thumbnail.\n        $thumb = \"themes://{$name}/thumbnail.jpg\";\n        $path = $this->grav['locator']->findResource($thumb, false);\n\n        if ($path) {","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Common/Themes.php#L154-L190","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before: config key typo yields null\n$data = $themes->get($grav['config']->get('system.pages.theme.missing'));\n\n// after\n$name = $grav['config']->get('system.pages.theme') ?: 'quark';\n$data = $name ? $themes->get($name) : null;","handlingStrategy":"validation","validationCode":"$name = is_string($name) ? trim($name) : '';\nif ($name === '') {\n    // skip, default, or raise your own clearer error — do not call Themes::get()\n    $name = $grav['config']->get('system.pages.theme') ?: 'quark';\n}\n$data = $grav['themes']->get($name); // null means unknown-but-named theme","typeGuard":"function isNonEmptyThemeName(mixed $name): bool\n{\n    return is_string($name) && trim($name) !== '';\n}","tryCatchPattern":"try { $themes->get($name); } catch (RuntimeException $e) { // programming error: log with backtrace, do not use as control flow\n    $grav['debugger']->addException($e); return null; }","preventionTips":["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"],"tags":["validation","theme","api-misuse","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}