{"record":{"id":"69a09a003f98d5ee","repo":"mermaid-js/mermaid","slug":"the-junction-id-id-is-already-in-use-by-anoth","errorCode":null,"errorMessage":"The junction id [${id}] is already in use by another ${this.registeredIds.get(id)}","messagePattern":"The junction id \\[(.+?)\\] is already in use by another (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/architecture/architectureDb.ts","lineNumber":120,"sourceCode":"\n    this.nodes.set(id, {\n      id,\n      type: 'service',\n      icon,\n      iconText,\n      title,\n      edges: [],\n      in: parent,\n    });\n  }\n\n  public getServices(): ArchitectureService[] {\n    return [...this.nodes.values()].filter(isArchitectureService);\n  }\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');","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L102-L138","documentation":"Thrown by addJunction when the junction id already exists in registeredIds. Junctions share the same id namespace as services and groups, so the suffix ('node' or 'group') in the message identifies the prior owner. Junctions themselves are stored as 'node', so a junction can also collide with a service.","triggerScenarios":"addJunction with an id already used by another junction, service, or group; adding a junction after a service with the same id.","commonSituations":"Auto-numbered junctions collide with service ids, or user text reuses a label for both a junction and a node.","solutions":["Use a distinct id namespace for junctions (e.g. prefix 'j_').","Check registeredIds/getNode before adding.","Rename the colliding entity if both must exist."],"exampleFix":"// before\ndb.addJunction({ id: 'j1' });\ndb.addJunction({ id: 'j1' }); // throws\n\n// after\ndb.addJunction({ id: 'j1' });\ndb.addJunction({ id: 'j2' });","handlingStrategy":"validation","validationCode":"if (db.getNode(id) !== null) {\n  throw new Error(`id '${id}' already in use`);\n}\ndb.addJunction({ id });","typeGuard":"function isJunctionIdFree(db: ArchitectureDB, id: string): boolean {\n  return db.getNode(id) === null;\n}","tryCatchPattern":null,"preventionTips":["Prefix junction ids (e.g. 'j_') to keep them distinct from services/groups.","Centralise id allocation in one helper that checks registeredIds."],"tags":["architecture","mermaid","validation","duplicate-id","junction"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}