{"record":{"id":"ea697df3931c302f","repo":"mermaid-js/mermaid","slug":"the-group-id-s-parent-does-not-exist-please","errorCode":null,"errorMessage":"The group [${id}]'s parent does not exist. Please make sure the parent is created before this group","messagePattern":"The group \\[(.+?)\\]'s parent does not exist\\. Please make sure the parent is created before this group","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/architecture/architectureDb.ts","lineNumber":171,"sourceCode":"    return [...this.nodes.values()];\n  }\n\n  public getNode(id: string): ArchitectureNode | null {\n    return this.nodes.get(id) ?? null;\n  }\n\n  public addGroup({ id, icon, in: parent, title }: ArchitectureGroup): void {\n    if (this.registeredIds.has(id)) {\n      throw new Error(\n        `The group id [${id}] is already in use by another ${this.registeredIds.get(id)}`\n      );\n    }\n    if (parent !== undefined) {\n      if (id === parent) {\n        throw new Error(`The group [${id}] cannot be placed within itself`);\n      }\n      if (!this.registeredIds.has(parent)) {\n        throw new Error(\n          `The group [${id}]'s parent does not exist. Please make sure the parent is created before this group`\n        );\n      }\n      if (this.registeredIds.get(parent) === 'node') {\n        throw new Error(`The group [${id}]'s parent is not a group`);\n      }\n    }\n\n    this.registeredIds.set(id, 'group');\n\n    this.groups.set(id, {\n      id,\n      icon,\n      title,\n      in: parent,\n    });\n  }\n  public getGroups(): ArchitectureGroup[] {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L153-L189","documentation":"Thrown by ArchitectureDB.addGroup when the `in` (parent) field references an id that is not present in registeredIds. Groups must be declared top-down: the parent must exist before any child group references it. The DB keeps a single registeredIds map of every node and group, and a miss here means the parent was never created.","triggerScenarios":"Calling db.addGroup({ id: 'child', in: 'parent' }) when 'parent' has not been added via addGroup/addService/addJunction yet. In DSL: declaring `group child in parent` before `group parent`.","commonSituations":"Ordering mistakes in hand-written DSL where a child group appears before its parent; programmatic API calls issued in the wrong sequence; renaming a parent without updating children.","solutions":["Declare the parent group (via addGroup) before declaring the child.","Drop the `in` field if the group is intended to be top-level.","Check for a typo in the parent id — it must match an existing registered id exactly."],"exampleFix":"// before\ndb.addGroup({ id: 'child', in: 'parent' }); // parent not declared\ndb.addGroup({ id: 'parent' });\n// after\ndb.addGroup({ id: 'parent' });\ndb.addGroup({ id: 'child', in: 'parent' });","handlingStrategy":"validation","validationCode":"function addGroupSafe(db, g) {\n  if (g.in !== undefined && !db.getGroups().some(gr => gr.id === g.in)\n      && !db.getNodes().some(n => n.id === g.in)) {\n    throw new Error(`Parent '${g.in}' is not registered`);\n  }\n  db.addGroup(g);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare parent groups before children.","Maintain a top-down declaration order when generating diagrams programmatically."],"tags":["architecture","hierarchy","ordering","group"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}