BookStackApp/BookStack · error · ThemeModuleException

Failed loading module from

Error message

Failed loading module from "{$moduleJsonFile}" with error: {$exception->getMessage()}

What it means

Wrapping ThemeModuleException rethrown in ThemeModuleManager::loadFromFolder when loading a module manifest fails for any reason (bad JSON or ThemeModule::fromJson validation failure); the original error text is embedded so the root cause of the failed module load is preserved.

Solutions

  1. Read the embedded original error message to identify whether it is invalid JSON or a missing/invalid manifest property
  2. Fix the bookstack-module.json accordingly (syntax or required name/description/version fields)
  3. Reinstall the theme module from a fresh copy if the file is corrupt
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at app/Theming/ThemeModuleManager.php:135 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02). Data as JSON: /api/errors/a727d77319a47253. Report an issue: GitHub.

Appendix: source

Thrown at app/Theming/ThemeModuleManager.php:135

    {
        $moduleJsonFile = $this->modulesFolderPath . DIRECTORY_SEPARATOR . $folderName . DIRECTORY_SEPARATOR . 'bookstack-module.json';
        if (!file_exists($moduleJsonFile)) {
            return null;
        }

        try {
            $jsonContent = file_get_contents($moduleJsonFile);
            $jsonData = json_decode($jsonContent, true);

            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new ThemeModuleException("Invalid JSON in module file at \"{$moduleJsonFile}\": " . json_last_error_msg());
            }

            $module = ThemeModule::fromJson($jsonData, $folderName);
        } catch (ThemeModuleException $exception) {
            throw $exception;
        } catch (\Exception $exception) {
            throw new ThemeModuleException("Failed loading module from \"{$moduleJsonFile}\" with error: {$exception->getMessage()}");
        }

        return $module;
    }
}

View on GitHub (pinned to 18f8469a1c)