flarum/framework · error · RuntimeException

Invalid image type

Error message

Invalid image type

What it means

Thrown in Extension::getIcon when the extension's composer.json declares extra.flarum-extension.icon.image pointing to a file whose extension is not in the LOGO_MIMETYPES allow-list (known image types only). The icon cannot be inlined as a base64 data URI, so building the extension's metadata fails with a RuntimeException. The faulting input is the icon image path/extension declared in the extension's composer.json.

Solutions

  1. Change the icon.image file in composer.json to a supported type (per LOGO_MIMETYPES, e.g. png)
  2. Rename/convert the icon file so its extension matches its actual format
  3. Report the issue to the extension author so they fix the declared icon
  4. Temporarily remove the icon.image key from composer.json
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at framework/core/src/Extension/Extension.php:251 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15). Data as JSON: /api/errors/997ab71e814ed07b. Report an issue: GitHub.

Appendix: source

Thrown at framework/core/src/Extension/Extension.php:251

    {
        return $this->abandoned;
    }

    public function getIcon(): ?array
    {
        $icon = $this->composerJsonAttribute('extra.flarum-extension.icon');
        $file = Arr::get($icon, 'image');

        if (is_null($icon) || is_null($file)) {
            return $icon;
        }

        $file = $this->path.'/'.$file;

        if (file_exists($file)) {
            $extension = pathinfo($file, PATHINFO_EXTENSION);
            if (! array_key_exists($extension, self::LOGO_MIMETYPES)) {
                throw new \RuntimeException('Invalid image type');
            }

            $mimetype = self::LOGO_MIMETYPES[$extension];
            $data = base64_encode(file_get_contents($file));

            $icon['backgroundImage'] = "url('data:$mimetype;base64,$data')";
        }

        return $icon;
    }

    public function getIconStyles(): string
    {
        $properties = $this->getIcon();

        if (empty($properties)) {
            return '';
        }

View on GitHub (pinned to 4b939f6853)