{"record":{"id":"5fde511f211b8a7f","repo":"mermaid-js/mermaid","slug":"the-group-id-s-parent-is-not-a-group","errorCode":null,"errorMessage":"The group [${id}]'s parent is not a group","messagePattern":"The group \\[(.+?)\\]'s parent is not a group","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/architecture/architectureDb.ts","lineNumber":176,"sourceCode":"  }\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[] {\n    return [...this.groups.values()];\n  }\n  public addEdge({\n    lhsId,\n    rhsId,","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L158-L194","documentation":"Thrown by ArchitectureDB.addGroup when the `in` (parent) field resolves to an id registered as a 'node' (a service or junction) rather than a 'group'. Only groups may contain other groups; services and junctions are leaf nodes and cannot be parents. The registeredIds map distinguishes the two kinds, and this check enforces the type constraint.","triggerScenarios":"Calling db.addGroup({ id: 'g', in: 'svc1' }) where 'svc1' was previously registered via addService or addJunction (registered as 'node').","commonSituations":"Confusing a service name with a group name when writing containment; typos where a group id collides with a service id; restructuring that moves groups under services.","solutions":["Point `in` at an id that was registered as a group (via addGroup).","If you intended the service to be a container, restructure — services cannot hold groups; promote it to a group instead."],"exampleFix":"// before\ndb.addService({ id: 'svc1' });\ndb.addGroup({ id: 'g', in: 'svc1' }); // svc1 is a node, not a group\n// after\ndb.addGroup({ id: 'outer' });\ndb.addGroup({ id: 'g', in: 'outer' });","handlingStrategy":"validation","validationCode":"function addGroupSafe(db, g) {\n  if (g.in !== undefined) {\n    const parentIsGroup = db.getGroups().some(gr => gr.id === g.in);\n    const parentIsNode = db.getNodes().some(n => n.id === g.in);\n    if (parentIsNode && !parentIsGroup) {\n      throw new Error(`Parent '${g.in}' is a node, not a group`);\n    }\n  }\n  db.addGroup(g);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only nest groups under other groups.","When refactoring, re-check that `in` does not point at a service or junction."],"tags":["architecture","hierarchy","type-mismatch","group"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}