{"record":{"id":"6cb57173279c6fd0","repo":"mermaid-js/mermaid","slug":"group-nodes-can-only-have-label-remove-the-additi","errorCode":null,"errorMessage":"Group nodes can only have label. Remove the additional description for node [${node.id}]","messagePattern":"Group nodes can only have label\\. Remove the additional description for node \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/state/stateDb.ts","lineNumber":285,"sourceCode":"      undefined,\n      this.getRootDocV2() as StateStmt,\n      diagramStates,\n      this.nodes,\n      this.edges,\n      true,\n      config.look,\n      this.classes\n    );\n\n    // Process node labels\n    for (const node of this.nodes) {\n      if (!Array.isArray(node.label)) {\n        continue;\n      }\n\n      node.description = node.label.slice(1);\n      if (node.isGroup && node.description.length > 0) {\n        throw new Error(\n          `Group nodes can only have label. Remove the additional description for node [${node.id}]`\n        );\n      }\n      node.label = node.label[0];\n    }\n  }\n\n  private handleStyleDef(item: StyleStmt) {\n    const ids = item.id.trim().split(',');\n    const styles = item.styleClass.split(',');\n\n    for (const id of ids) {\n      let state = this.getState(id);\n      if (!state) {\n        const trimmedId = id.trim();\n        this.addState(trimmedId);\n        state = this.getState(trimmedId);\n      }","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/state/stateDb.ts#L267-L303","documentation":"During state diagram finalize, each node's label array is split: index 0 becomes the label, the rest become the description. If the node is a composite/group (isGroup) and that leftover description is non-empty, mermaid throws because group nodes may carry only a label — extra text is ambiguous for the nested states.","triggerScenarios":"Declaring a composite state with more than one string in its label, e.g. `state \"X\\nY\" as S { ... }` or any group node receiving a multi-part label.","commonSituations":"Trying to annotate a composite state with a sub-caption; pasting a state definition that used a newline/colon separator inside a group; generated diagrams attaching descriptions to every node including composites.","solutions":["Give the group node a single label only; move any extra text into a `note` or a child state.","Split the multi-part label into the group label plus a `note left/right of <id>`.","If the description belongs to a leaf, target that leaf state instead of the group.","Check that code generation does not append descriptions to composite nodes."],"exampleFix":"// before — composite state carries an extra description\nstate \"Main\\nSubtitle\" as Main { [*] --> A }\n\n// after\nstate Main { [*] --> A }\nnote right of Main : Subtitle","handlingStrategy":"validation","validationCode":"// Reject composite states that carry extra label parts before rendering\nfor (const node of nodes) {\n  if (node.isGroup && Array.isArray(node.label) && node.label.length > 1) {\n    throw new Error(`Group ${node.id} may only have a single label`);\n  }\n}","typeGuard":"const isGroupLabelError = (e): boolean =>\n  e instanceof Error && /Group nodes can only have label/.test(e.message);","tryCatchPattern":"try {\n  await mermaid.run({ nodes: [el] });\n} catch (e) {\n  if (e instanceof Error && /Group nodes can only have label/.test(e.message)) {\n    // move the extra text into a note or a child state\n  } else { throw e; }\n}","preventionTips":["Give composite/group states a single label only.","Use `note` for any extra annotation on a group.","Lint generated diagrams so descriptions target leaf states."],"tags":["state","composite-node","label","validation"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}