{"record":{"id":"f7152a0f9a4d82db","repo":"mermaid-js/mermaid","slug":"c4-no-shape-handler-for-node-shape","errorCode":null,"errorMessage":"C4: no shape handler for \"${node.shape}\"","messagePattern":"C4: no shape handler for \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/c4/c4Renderer.ts","lineNumber":279,"sourceCode":"  currentBounds: Bounds,\n  diagram: SVG,\n  c4ShapeArray: C4Shape[],\n  c4ShapeKeys: string[]\n) {\n  const mermaidConfig = getConfig();\n  const look = mermaidConfig.look ?? 'classic';\n  const renderOptions = { config: mermaidConfig };\n  // Namespace the shape DOM ids with the diagram id so two diagrams on one page don't\n  // collide (the unified shapes use node.domId for the element id).\n  const diagramId = diagram.attr('id') ?? '';\n\n  // `c4ShapeKeys` are the (numeric string) indices of `c4ShapeArray`.\n  const c4Shapes = c4ShapeKeys.map((key) => c4ShapeArray[Number(key)]);\n\n  const shapeHandlerFor = (node: ReturnType<typeof buildC4Node>) => {\n    const handler = node.shape ? shapes[node.shape] : undefined;\n    if (!handler) {\n      throw new Error(`C4: no shape handler for \"${node.shape}\"`);\n    }\n    return handler;\n  };\n\n  // Pass 1 (measure): render each shape, read its self-sized dimensions onto the legacy\n  // c4Shape, then discard the rendering. The shape is drawn again in pass 2 directly at its\n  // final position, so its label (and any composited sub-element) lays out under the final\n  // transform - drawing at the origin and translating afterwards leaves composited layers\n  // (e.g. anything with opacity) painting at the stale origin.\n  await Promise.all(\n    c4Shapes.map(async (c4Shape) => {\n      const node = buildC4Node(c4Shape, conf, conf.c4ShapePadding, look, conf.width);\n      node.domId = `${diagramId}-${node.id}`;\n      const measured = await shapeHandlerFor(node)(diagram, node, renderOptions);\n      c4Shape.width = node.width ?? conf.width;\n      c4Shape.height = node.height ?? conf.height;\n      c4Shape.margin = conf.c4ShapeMargin;\n      measured.remove();","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/c4/c4Renderer.ts#L261-L297","documentation":"Thrown by the C4 renderer's shapeHandlerFor helper when a built C4 node's `shape` is falsy or has no entry in the unified `shapes` registry. The renderer looks up `shapes[node.shape]`; a miss means the C4 diagram produced a shape type the renderer cannot draw. This is generally an internal/version-mismatch issue rather than a user DSL error, since the C4 grammar only emits known shape keys.","triggerScenarios":"A C4 diagram where buildC4Node returns a shape string that is not a key in the shapes registry — e.g. due to a custom or experimental shape, or a shape key renamed/removed in a version transition where the c4 DB and the shapes registry disagree.","commonSituations":"Mermaid version mismatch where c4Renderer expects a shape the installed shapes module doesn't register; third-party extensions adding C4 types without a render handler; partial upgrades.","solutions":["Upgrade mermaid to a consistent version where c4Renderer and the shapes registry agree.","Remove any custom/experimental C4 shape types from the diagram and use the built-in types.","If it reproduces on the latest version with a standard C4 diagram, report it as a bug — the message is intended for exactly that case."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await mermaid.render(id, c4DiagramText);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('C4: no shape handler')) {\n    // Unsupported C4 shape for this mermaid version — simplify the diagram or upgrade.\n  }\n  throw err;\n}","preventionTips":["Use only the built-in C4 element types (Person, System, Container, Component, Boundary, etc.).","Keep mermaid at a consistent version across the c4 DB and the shapes registry."],"tags":["c4","shape","internal","renderer"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}