{"record":{"id":"0bb39f19c3894db5","repo":"laravel/framework","slug":"the-font-manifest-at-path-is-not-valid-json","errorCode":null,"errorMessage":"The font manifest at [{$path}] is not valid JSON.","messagePattern":"The font manifest at \\[(.+?)\\] is not valid JSON\\.","errorType":"exception","errorClass":"ViteException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Foundation/ViteFonts.php","lineNumber":57,"sourceCode":"     *\n     * @throws \\Illuminate\\Foundation\\ViteException\n     */\n    protected function readManifest(string $path)\n    {\n        if (isset(static::$manifests[$path])) {\n            return static::$manifests[$path];\n        }\n\n        if (! is_file($path)) {\n            return null;\n        }\n\n        $contents = file_get_contents($path);\n\n        $manifest = json_decode($contents, true);\n\n        if (json_last_error() !== JSON_ERROR_NONE) {\n            throw new ViteException(\"The font manifest at [{$path}] is not valid JSON.\");\n        }\n\n        return static::$manifests[$path] = $manifest;\n    }\n\n    /**\n     * Resolve the CSS content from the manifest.\n     *\n     * @param  array<string, mixed>  $manifest\n     * @param  list<string>|null  $aliases\n     * @param  string  $buildDirectory\n     * @return string\n     *\n     * @throws \\Illuminate\\Foundation\\ViteException\n     */\n    public function resolveStyleContent(array $manifest, ?array $aliases, string $buildDirectory)\n    {\n        $style = $manifest['style'] ?? null;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Foundation/ViteFonts.php#L39-L75","documentation":"ViteFonts::manifest() reads a font manifest JSON file (path supplied by the developer) and throws ViteException if json_decode reports an error. This protects callers from silently feeding malformed data into the CSS-resolution logic. Only triggered when the file exists and is non-JSON.","triggerScenarios":"A font manifest path is configured and the file at that path exists but is not parseable JSON — truncated, hand-edited, BOM-prefixed, contains a PHP error mixed in, or was written by a process that errored midway.","commonSituations":"Vite font plugin output corrupted by a failed/aborted build. Manual edits to the manifest that broke syntax. A different file written to the expected path (e.g. an error page from a CDN). Version mismatch between the font plugin and the consuming code expecting a newer schema.","solutions":["Regenerate the font manifest by rerunning the Vite build / font plugin pipeline.","Validate the file with a JSON linter (jq . <path>) to find the syntax error.","Confirm the configured path points to the actual generated manifest, not a staging or template file.","Upgrade or downgrade the Vite font plugin to a version whose output this ViteFonts version understands."],"exampleFix":"// before — manifest file contains a stray trailing comma\n{ \"family\": \"Inter\", }\n\n// after\n{ \"family\": \"Inter\" }","handlingStrategy":"validation","validationCode":"$path = config('vite.fonts_manifest_path');\nif ($path && is_file($path)) {\n    json_decode(file_get_contents($path), true);\n    if (json_last_error() !== JSON_ERROR_NONE) {\n        throw new RuntimeException('Font manifest invalid JSON: '.json_last_error_msg());\n    }\n}","typeGuard":"function fontManifestIsValidJson(string $path): bool {\n    if (! is_file($path)) return true; // missing file does not throw\n    json_decode(file_get_contents($path), true);\n    return json_last_error() === JSON_ERROR_NONE;\n}","tryCatchPattern":"use Illuminate\\Foundation\\ViteException;\n\ntry {\n    $fonts = app('vite.fonts')->manifest($path);\n} catch (ViteException $e) {\n    // regenerate manifest or skip font injection\n}","preventionTips":["Treat the font manifest as a build artifact; never hand-edit.","Validate JSON in CI for committed manifests.","Pin the font plugin version that produces the expected schema.","Regenerate manifests after every Vite upgrade."],"tags":["vite","laravel","fonts","json","manifest"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}