{"record":{"id":"9ebb53e0ed164aef","repo":"mermaid-js/mermaid","slug":"the-right-hand-id-rhsid-does-not-yet-exist-p","errorCode":null,"errorMessage":"The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it.","messagePattern":"The right-hand id \\[(.+?)\\] does not yet exist\\. Please create the service/group before declaring an edge to it\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/architecture/architectureDb.ts","lineNumber":220,"sourceCode":"  }: ArchitectureEdge): void {\n    if (!isArchitectureDirection(lhsDir)) {\n      throw new Error(\n        `Invalid direction given for left hand side of edge ${lhsId}--${rhsId}. Expected (L,R,T,B) got ${String(lhsDir)}`\n      );\n    }\n    if (!isArchitectureDirection(rhsDir)) {\n      throw new Error(\n        `Invalid direction given for right hand side of edge ${lhsId}--${rhsId}. Expected (L,R,T,B) got ${String(rhsDir)}`\n      );\n    }\n\n    if (!this.nodes.has(lhsId) && !this.groups.has(lhsId)) {\n      throw new Error(\n        `The left-hand id [${lhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`\n      );\n    }\n    if (!this.nodes.has(rhsId) && !this.groups.has(rhsId)) {\n      throw new Error(\n        `The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`\n      );\n    }\n\n    const lhsGroupId = this.nodes.get(lhsId)!.in;\n    const rhsGroupId = this.nodes.get(rhsId)!.in;\n    if (lhsGroup && lhsGroupId && rhsGroupId && lhsGroupId == rhsGroupId) {\n      throw new Error(\n        `The left-hand id [${lhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups.`\n      );\n    }\n    if (rhsGroup && lhsGroupId && rhsGroupId && lhsGroupId == rhsGroupId) {\n      throw new Error(\n        `The right-hand id [${rhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups.`\n      );\n    }\n\n    const edge = {","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L202-L238","documentation":"Thrown by ArchitectureDB.addEdge when rhsId is in neither the nodes nor the groups map. Same contract as the LHS check but for the right-hand endpoint; reaching it means lhsId was valid but rhsId was not.","triggerScenarios":"Calling db.addEdge({ lhsId: 'a', rhsId: 'ghost', lhsDir: 'L', rhsDir: 'R' }) where 'ghost' was never registered.","commonSituations":"Edge declared before the right-hand target exists; typo in rhs id; id from a stale/cleared DB.","solutions":["Declare the right-hand service, junction, or group first.","Verify the spelling and case of rhsId."],"exampleFix":"// before\ndb.addEdge({ lhsId: 'a', rhsId: 'b', lhsDir: 'L', rhsDir: 'R' }); // 'b' not declared\n// after\ndb.addService({ id: 'a' });\ndb.addService({ id: 'b' });\ndb.addEdge({ lhsId: 'a', rhsId: 'b', lhsDir: 'L', rhsDir: 'R' });","handlingStrategy":"validation","validationCode":"function addEdgeSafe(db, e) {\n  const exists = (id) => db.getNode(id) !== null || db.getGroups().some(g => g.id === id);\n  if (!exists(e.rhsId)) {\n    throw new Error(`rhsId '${e.rhsId}' is not declared`);\n  }\n  db.addEdge(e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the right-hand endpoint is declared before addEdge.","Validate both endpoint ids against the DB before constructing edges."],"tags":["architecture","edge","ordering","reference"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}