{"record":{"id":"4b1185cbf3a06772","repo":"vuejs/vue","slug":"invalid-server-rendering-bundle-format-should-be","errorCode":null,"errorMessage":"Invalid server-rendering bundle format. Should be a string or a bundle Object of type:\\n\\n{\n  entry: string;\n  files: { [filename: string]: string; };\n  maps: { [filename: string]: string; };\n}\n","messagePattern":"Invalid server-rendering bundle format\\. Should be a string or a bundle Object of type:\\\\n\\\\n(.+?);\n  maps: (.+?);\n\\}\n","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server-renderer/src/bundle-renderer/create-bundle-renderer.ts","lineNumber":71,"sourceCode":"          try {\n            // @ts-expect-error\n            bundle = JSON.parse(bundle)\n          } catch (e: any) {\n            throw new Error(`Invalid JSON bundle file: ${bundle}`)\n          }\n        }\n      } else {\n        throw new Error(`Cannot locate bundle file: ${bundle}`)\n      }\n    }\n\n    if (typeof bundle === 'object') {\n      entry = bundle.entry\n      files = bundle.files\n      basedir = basedir || bundle.basedir\n      maps = createSourceMapConsumers(bundle.maps)\n      if (typeof entry !== 'string' || typeof files !== 'object') {\n        throw new Error(INVALID_MSG)\n      }\n    } else if (typeof bundle === 'string') {\n      entry = '__vue_ssr_bundle__'\n      files = { __vue_ssr_bundle__: bundle }\n      maps = {}\n    } else {\n      throw new Error(INVALID_MSG)\n    }\n\n    const renderer = createRenderer(rendererOptions)\n\n    const run = createBundleRunner(\n      entry,\n      files,\n      basedir,\n      rendererOptions.runInNewContext\n    )\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/vuejs/vue/blob/9e88707940088cb1f4cd7dd210c9168a50dc347c/packages/server-renderer/src/bundle-renderer/create-bundle-renderer.ts#L53-L89","documentation":"Thrown when the bundle is an object but its shape is wrong: either bundle.entry is not a string, or bundle.files is not an object. createBundleRenderer expects a RenderBundle of type { entry: string; files: { [name]: string }; maps: { [name]: string }; basedir? }. This guard fires after the object has already been destructured, so a missing entry key (undefined) or a files value that is an array/string triggers it.","triggerScenarios":"Passing a hand-built object missing the entry property, with entry set to a number, or with files as an array or string instead of a key-value map. Also fires if the JSON manifest from a non-standard or older webpack plugin has a different schema.","commonSituations":"Loading a client manifest (vue-ssr-client-manifest.json) into createBundleRenderer instead of the server bundle. Passing a raw webpack stats object. Constructing a bundle object manually with a typo in the key name (e.g. entries instead of entry).","solutions":["Ensure the object has entry (string), files (object of filename->content strings), and maps (object).","Load the server bundle JSON produced by VueSSRServerPlugin, not the client manifest.","If passing a single bundled JS string, pass it as a string argument instead of wrapping it incorrectly in an object.","Inspect the object with console.log(Object.keys(bundle)) to verify the expected keys exist."],"exampleFix":"// before — wrong object shape\ncreateBundleRenderer({ entries: 'main.js', files: ['main.js'] })\n\n// after — correct RenderBundle\ncreateBundleRenderer({\n  entry: 'main.js',\n  files: { 'main.js': bundleSourceString },\n  maps: {}\n})","handlingStrategy":"type-guard","validationCode":"function assertRenderBundleShape(bundle: unknown): void {\n  if (typeof bundle !== 'object' || bundle === null) {\n    throw new Error('bundle must be an object')\n  }\n  const b = bundle as any\n  if (typeof b.entry !== 'string') throw new Error('bundle.entry must be a string')\n  if (typeof b.files !== 'object' || b.files === null) throw new Error('bundle.files must be an object')\n}\n\nassertRenderBundleShape(bundle)\ncreateBundleRenderer(bundle)","typeGuard":"type RenderBundle = { entry: string; files: Record<string, string>; maps?: Record<string, string>; basedir?: string }\n\nfunction isRenderBundle(v: unknown): v is RenderBundle {\n  if (typeof v !== 'object' || v === null) return false\n  const o = v as Record<string, unknown>\n  return typeof o.entry === 'string' && typeof o.files === 'object' && o.files !== null\n}","tryCatchPattern":"try {\n  createBundleRenderer(bundle)\n} catch (e) {\n  if (e.message.includes('Invalid server-rendering bundle format')) {\n    console.error('Bundle shape invalid. Keys:', Object.keys(bundle || {}))\n  }\n  throw e\n}","preventionTips":["Always load the server bundle JSON produced by VueSSRServerPlugin; do not construct it manually.","Distinguish server bundle (entry/files/maps) from client manifest (publicPath/all/initial/async) by key presence.","Type the bundle as RenderBundle in your codebase so TypeScript catches shape errors at compile time.","Add a schema validation step (e.g. ajv) in CI against the emitted manifest."],"tags":["ssr","bundle-renderer","validation","schema","typescript"],"analyzedSha":"9e88707940088cb1f4cd7dd210c9168a50dc347c","analyzedAt":"2026-08-11T22:22:01.295Z","schemaVersion":2},"datasetVersion":"2026-08-12T04:17:13.124Z"}