laravel/framework · error · ViteException

The font manifest [style.familyStyles] must be an object key

Error message

The font manifest [style.familyStyles] must be an object keyed by alias; the manifest was likely produced by an incompatible plugin version.

What it means

Inside resolveFilteredStyleContent(), the code expects $style['familyStyles'] to be an associative array keyed by alias. If the key is present but not an array (e.g. a string, int, or nested object of the wrong shape), ViteException is thrown. The message explicitly blames an incompatible plugin version, because the familyStyles object schema is a contract between the font plugin and this resolver.

Source

Thrown at src/Illuminate/Foundation/ViteFonts.php:101

        };
    }

    /**
     * Resolve filtered CSS content using per-alias fragments from the manifest.
     *
     * @param  array{inline?: string, file?: string, familyStyles?: array<string, string>, variables?: array<string, string>}  $style
     * @param  list<string>  $aliases
     * @return string
     *
     * @throws \Illuminate\Foundation\ViteException
     */
    protected function resolveFilteredStyleContent(array $style, array $aliases)
    {
        $familyStyles = $style['familyStyles'] ?? [];
        $variables = $style['variables'] ?? [];

        if (! is_array($familyStyles)) {
            throw new ViteException(
                'The font manifest [style.familyStyles] must be an object keyed by alias; the manifest was likely produced by an incompatible plugin version.'
            );
        }

        if (! is_array($variables)) {
            throw new ViteException(
                'The font manifest [style.variables] must be an object keyed by alias; the manifest was likely produced by an incompatible plugin version.'
            );
        }

        $parts = [];

        foreach ($aliases as $alias) {
            if (isset($familyStyles[$alias])) {
                $parts[] = $familyStyles[$alias];
            }
        }

View on GitHub (pinned to e0f6eb3518)

Solutions

  1. Align versions: use the font plugin version documented for this Laravel release.
  2. Regenerate the manifest so familyStyles is an object keyed by alias, e.g. {"default": "@font-face {...}"}.
  3. Inspect the offending style entry with jq '.styles[] | {familyStyles}' to see the wrong shape.
  4. If you cannot change the producer, filter the alias list passed to resolveFilteredStyleContent to aliases that match the producer's schema.

Example fix

// before — producer emits a string
{ "style": { "familyStyles": "@font-face{...}" } }

// after — alias-keyed object
{ "style": { "familyStyles": { "default": "@font-face{...}" } } }
Defensive patterns

Strategy: validation

Validate before calling

$manifest = json_decode(file_get_contents($path), true);
foreach ($manifest['styles'] ?? [] as $style) {
    if (isset($style['familyStyles']) && ! is_array($style['familyStyles'])) {
        throw new RuntimeException('familyStyles must be an object; plugin version mismatch.');
    }
}

Type guard

function familyStylesWellShaped(array $style): bool {
    return ! isset($style['familyStyles']) || is_array($style['familyStyles']);
}

Try / catch

use Illuminate\Foundation\ViteException;

try {
    $css = $viteFonts->resolveFilteredStyleContent($style, $aliases);
} catch (ViteException $e) {
    if (str_contains($e->getMessage(), 'familyStyles')) { /* rebuild manifest */ }
}

Prevention

When it happens

Trigger: The font manifest's style entries have a 'familyStyles' field that is not a JSON object. Happens when the font plugin that wrote the manifest emits familyStyles as a flat string, a list, or omits the alias-keyed object shape this version of ViteFonts expects.

Common situations: Upgrading Laravel/Vite integration without upgrading the font plugin, or vice versa. Mixing manifests from a different font pipeline (e.g. switched from one Vite font plugin to another). Editing the manifest by hand.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/28e0757711590f44. Report an issue: GitHub.