{"record":{"id":"acddc6da5ebedfe6","repo":"mermaid-js/mermaid","slug":"groups-within-groups-are-not-allowed-in-kanban-dia","errorCode":null,"errorMessage":"Groups within groups are not allowed in Kanban diagrams","messagePattern":"Groups within groups are not allowed in Kanban diagrams","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/kanban/kanbanRenderer.ts","lineNumber":76,"sourceCode":"    // Todo, use theme variable THEME_COLOR_LIMIT instead of 10\n    section.cssClasses = section.cssClasses + ' section-' + cnt;\n    const sectionObj = await insertCluster(sectionsElem, section);\n    maxLabelHeight = Math.max(maxLabelHeight, sectionObj?.labelBBox?.height);\n    sectionObjects.push(sectionObj);\n  }\n  let i = 0;\n  for (const section of sections) {\n    const sectionObj = sectionObjects[i];\n    i = i + 1;\n    const WIDTH = conf?.kanban?.sectionWidth || 200;\n    const top = (-WIDTH * 3) / 2 + maxLabelHeight;\n    let y = top;\n    const sectionItems = data4Layout.nodes.filter((node) => node.parentId === section.id);\n    for (const item of sectionItems) {\n      if (item.isGroup) {\n        // Kanban diagrams should not have groups within groups\n        // this should never happen\n        throw new Error('Groups within groups are not allowed in Kanban diagrams');\n      }\n      item.x = section.x;\n      item.width = WIDTH - 1.5 * padding;\n      const nodeEl = await insertNode(nodesElem, item, { config: conf });\n      const bbox = nodeEl.node()!.getBBox();\n      item.y = y + bbox.height / 2;\n      await positionNode(item);\n      y = item.y + bbox.height / 2 + padding / 2;\n    }\n    const rect = sectionObj.cluster.select('rect');\n    const height = Math.max(y - top + 3 * padding, 50) + (maxLabelHeight - 25);\n    rect.attr('height', height);\n  }\n\n  // Setup the view box and size of the svg element\n  setupGraphViewbox(\n    undefined,\n    svg,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/kanban/kanbanRenderer.ts#L58-L94","documentation":"Thrown by the kanban renderer while laying out items inside a section: an item whose parentId matches the section has isGroup === true. The code comment explicitly says 'this should never happen' — kanban sections are the only grouping level allowed, and nested groups (a group inside a section item) are structurally unsupported. Reaching this throw means the db produced a node tree the renderer cannot lay out.","triggerScenarios":"Programmatically constructing a kanban db where a section's child is marked isGroup; a parser bug that sets isGroup on a leaf item; tampering with the parsed node objects between parse and render.","commonSituations":"Not reachable through normal kanban text syntax — the grammar does not let users declare nested groups; appears only with custom/programmatic diagram construction, internal bugs, or forked parser changes.","solutions":["If you construct kanban nodes programmatically, ensure no child of a section has isGroup set to true — only sections are groups.","If this occurs with plain text input, report it upstream as a parser bug with the reproducing diagram.","Upgrade mermaid to the latest version.","Inspect the parsed node tree (log data4Layout.nodes) to find which item wrongly has isGroup === true and fix its source."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function noNestedGroups(nodes: {id:string;parentId?:string;isGroup:boolean}[], sections: {id:string}[]): boolean {\n  const sectionIds = new Set(sections.map(s => s.id));\n  return nodes.every(n => !n.isGroup || sectionIds.has(n.parentId ?? ''));\n}","tryCatchPattern":"try {\n  await mermaid.render('g', diagramText);\n} catch (e) {\n  if (e instanceof Error && /Groups within groups are not allowed/.test(e.message)) {\n    showUserError('Internal kanban structure error: a section item is marked as a group. Report this if using standard syntax.');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Do not programmatically set isGroup on kanban leaf items.","Use the standard kanban text grammar which cannot produce nested groups.","Report occurrences with valid text input upstream."],"tags":["mermaid","kanban","rendering","internal-invariant"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}