{"id":"5c7f7cd026c4bf45","repo":"prettier/prettier","slug":"printer-embed-has-too-many-parameters-the-api-cha","errorCode":null,"errorMessage":"printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed","messagePattern":"printer\\.embed has too many parameters\\. The API changed in Prettier v3\\. Please update your plugin\\. See https://prettier\\.io/docs/plugins#optional-embed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/multiparser.js","lineNumber":26,"sourceCode":"  /** @type {AstPath} */ path,\n  genericPrint,\n  options,\n  printAstToDoc,\n  embeds,\n) {\n  if (options.embeddedLanguageFormatting !== \"auto\") {\n    return;\n  }\n\n  const { printer } = options;\n  const { embed } = printer;\n\n  if (!embed) {\n    return;\n  }\n\n  if (embed.length > 2) {\n    throw new Error(\n      \"printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed\",\n    );\n  }\n\n  const { hasPrettierIgnore } = printer;\n  const { getVisitorKeys } = embed;\n\n  const embedCallResults = [];\n\n  recurse();\n\n  const originalPathStack = path.stack;\n\n  for (const { print, node, pathStack } of embedCallResults) {\n    try {\n      path.stack = pathStack;\n      const doc = await print(textToDocForEmbed, genericPrint, path, options);\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/prettier/prettier/blob/315f28198200d7678dadd3fd5eece499b127ff2a/src/main/multiparser.js#L8-L44","documentation":"In Prettier v3 the `embed` API changed: it now takes `(path, options)` and returns a function, instead of v2's `(path, print, textToDoc, options)`. The multiparser checks `embed.length > 2` (src/main/multiparser.js:26) and throws immediately so outdated plugins fail fast with an actionable migration message.","triggerScenarios":"Loading a Prettier v2 plugin whose printer.embed declares 3 or 4 parameters into a Prettier v3 host. Common when upgrading an app to Prettier 3 while a community plugin has not published a v3-compatible release.","commonSituations":"Major-version Prettier upgrade with stale plugins; plugin peerDependencies still pinned to prettier 2.","solutions":["Upgrade the plugin to a Prettier v3-compatible release.","If you own the plugin, rewrite embed to the v3 signature: `embed(path, options)` returning an async `(textToDoc) => doc` function.","Temporarily remove the incompatible plugin until it ships a v3 build.","Verify the plugin's peerDependencies declare prettier 3 support."],"exampleFix":"// before (v2 embed)\nfunction embed(path, print, textToDoc, options) {\n  // ...\n}\n\n// after (v3 embed)\nfunction embed(path, options) {\n  return async (textToDoc) => {\n    // ...\n  };\n}","handlingStrategy":"validation","validationCode":"// Reject plugins with an outdated embed signature before registering them\nfunction isV3CompatiblePlugin(plugin) {\n  for (const printer of Object.values(plugin?.printers ?? {})) {\n    const embed = printer?.embed;\n    if (typeof embed === \"function\" && embed.length > 2) return false;\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After upgrading Prettier major versions, audit every plugin for v3 compatibility.","Pin plugins that declare the correct prettier peer range.","Gate plugin registration on an embed.length <= 2 check."],"tags":["plugin","v3-migration","embed","breaking-change"],"analyzedSha":"315f28198200d7678dadd3fd5eece499b127ff2a","analyzedAt":"2026-08-03T19:59:41.458Z","schemaVersion":2}