{"record":{"id":"80c178dc369e97f2","repo":"prettier/prettier","slug":"unexpected-postcss-node-type-json-stringify-nod","errorCode":null,"errorMessage":"Unexpected PostCSS node type: ${JSON.stringify(node.type)}.","messagePattern":"Unexpected PostCSS node type: (.+?)\\.","errorType":"exception","errorClass":"UnexpectedNodeError","httpStatus":null,"severity":"error","filePath":"src/language-css/printer-postcss.js","lineNumber":513,"sourceCode":"      return printString(\n        node.raws.quote + node.value + node.raws.quote,\n        options,\n      );\n\n    case \"value-atword\":\n      return [\"@\", node.value];\n\n    case \"value-unicode-range\":\n      return node.value;\n\n    case \"value-unknown\":\n      return node.value;\n\n    case \"front-matter\": // Handled in core\n    case \"value-comma\": // Handled in `value-comma_group`\n    default:\n      /* c8 ignore next */\n      throw new UnexpectedNodeError(node, \"PostCSS\");\n  }\n}\n\nconst printer = {\n  features: {\n    experimental_frontMatterSupport: {\n      massageAstNode: true,\n      embed: true,\n      print: true,\n    },\n  },\n  print: genericPrint,\n  embed,\n  insertPragma,\n  massageAstNode,\n  getVisitorKeys,\n};\n","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/prettier/prettier/blob/903845c7d16ce66dedd9d5ab4b858d233f48341a/src/language-css/printer-postcss.js#L495-L531","documentation":"The CSS/SCSS/Less printer's switch statement handles every known PostCSS AST node type. The default branch (src/language-css/printer-postcss.js:511-513) throws UnexpectedNodeError if a node type is not recognized. This is marked `c8 ignore` — it is a defensive invariant never expected to fire; hitting it means the parser produced a node the printer does not know how to render.","triggerScenarios":"A new or experimental PostCSS/postcss-values parser node type the current printer version doesn't handle. A custom plugin that injects synthetic PostCSS nodes with an unknown type. A version mismatch between the bundled postcss parser and the printer.","commonSituations":"Upgrading postcss or a postcss plugin independently of prettier. Using bleeding-edge or non-standard CSS syntax. A third-party plugin mutating the AST after parsing.","solutions":["Upgrade prettier to the latest version that may recognize the new node type.","Identify the offending CSS construct from the reported node type and simplify or remove it.","Disable the custom postcss/plugin pipeline and re-run to isolate whether a plugin injected the node.","If reproducible on current prettier, file an issue with the minimal CSS snippet and node type."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const SUPPORTED_TYPES = new Set([/* enumerate css node types your tooling uses */]);\n// Walk the PostCSS AST and assert node.type is in SUPPORTED_TYPES before formatting.","typeGuard":null,"tryCatchPattern":"try {\n  await prettier.format(css, { parser: \"css\" });\n} catch (error) {\n  if (error.name === \"UnexpectedNodeError\") {\n    console.error(\"Unsupported CSS node type:\", error.node?.type);\n  } else throw error;\n}","preventionTips":["Keep prettier and postcss versions in lockstep (use the bundled postcss).","Avoid injecting synthetic PostCSS nodes from custom plugins.","Repro on the latest prettier before reporting; simplify the CSS to isolate the node."],"tags":["css","parser","ast","internal"],"backgroundTag":null,"analyzedSha":"903845c7d16ce66dedd9d5ab4b858d233f48341a","analyzedAt":"2026-08-09T13:56:28.558Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}