{"record":{"id":"7a177f4763df9d07","repo":"mermaid-js/mermaid","slug":"the-junction-id-s-parent-is-not-a-group","errorCode":null,"errorMessage":"The junction [${id}]'s parent is not a group","messagePattern":"The junction \\[(.+?)\\]'s parent is not a group","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/architecture/architectureDb.ts","lineNumber":134,"sourceCode":"  }\n\n  public addJunction({ id, in: parent }: Omit<ArchitectureJunction, 'edges'>): void {\n    if (this.registeredIds.has(id)) {\n      throw new Error(\n        `The junction 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 junction [${id}] cannot be placed within itself`);\n      }\n      if (!this.registeredIds.has(parent)) {\n        throw new Error(\n          `The junction [${id}]'s parent does not exist. Please make sure the parent is created before this junction`\n        );\n      }\n      if (this.registeredIds.get(parent) === 'node') {\n        throw new Error(`The junction [${id}]'s parent is not a group`);\n      }\n    }\n\n    this.registeredIds.set(id, 'node');\n\n    this.nodes.set(id, {\n      id,\n      type: 'junction',\n      edges: [],\n      in: parent,\n    });\n  }\n\n  public getJunctions(): ArchitectureJunction[] {\n    return [...this.nodes.values()].filter(isArchitectureJunction);\n  }\n\n  public getNodes(): ArchitectureNode[] {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L116-L152","documentation":"Thrown by addJunction when the referenced parent exists but is tagged 'node' rather than 'group'. Only groups can contain junctions, so nesting a junction under a service or another junction is rejected.","triggerScenarios":"addJunction({ id: 'j', in: 'svc' }) where 'svc' was added via addService or addJunction (both 'node').","commonSituations":"User places a junction inside a service instead of a group, or chains junctions under each other.","solutions":["Put the junction inside a group: addGroup first, then addJunction with in:<groupId>.","If the intended container is a node, wrap both in a group."],"exampleFix":"// before\ndb.addService({ id: 'svc' });\ndb.addJunction({ id: 'j', in: 'svc' }); // throws\n\n// after\ndb.addGroup({ id: 'box' });\ndb.addJunction({ id: 'j', in: 'box' });","handlingStrategy":"validation","validationCode":"if (parent) {\n  const isGroup = db.getGroups().some((g) => g.id === parent);\n  if (!isGroup) throw new Error(`'${parent}' is not a group`);\n}\ndb.addJunction({ id, in: parent });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only nest junctions under groups.","Wrap services+junctions in a group when containment is needed."],"tags":["architecture","mermaid","validation","parent","group","junction"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}