{"record":{"id":"d9e1b16420f6bf8c","repo":"mermaid-js/mermaid","slug":"the-left-hand-id-lhsid-does-not-yet-exist-pl","errorCode":null,"errorMessage":"The left-hand id [${lhsId}] does not yet exist. Please create the service/group before declaring an edge to it.","messagePattern":"The left-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":215,"sourceCode":"    lhsInto,\n    rhsInto,\n    lhsGroup,\n    rhsGroup,\n    title,\n  }: 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(","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L197-L233","documentation":"Thrown by ArchitectureDB.addEdge when lhsId is present in neither the nodes map (services/junctions) nor the groups map. Both endpoints of an edge must be declared before the edge is added. The LHS check runs first, so this is the endpoint error you hit when the left-hand side is the missing one.","triggerScenarios":"Calling db.addEdge({ lhsId: 'ghost', rhsId: 'a', lhsDir: 'L', rhsDir: 'R' }) where 'ghost' was never registered via addService/addJunction/addGroup.","commonSituations":"Declaring an edge before the service/group it connects; typo in the lhs id; referencing an id declared in a different/cleared DB instance.","solutions":["Declare the left-hand service, junction, or group before calling addEdge.","Check the spelling and case of lhsId against the declaration."],"exampleFix":"// before\ndb.addEdge({ lhsId: 'api', rhsId: 'db', lhsDir: 'L', rhsDir: 'R' }); // 'api' not declared\n// after\ndb.addService({ id: 'api' });\ndb.addService({ id: 'db' });\ndb.addEdge({ lhsId: 'api', rhsId: 'db', 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.lhsId)) {\n    throw new Error(`lhsId '${e.lhsId}' is not declared`);\n  }\n  db.addEdge(e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare all services, junctions, and groups before any edge that references them.","When generating from external data, sort declarations before edges."],"tags":["architecture","edge","ordering","reference"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}