mermaid-js/mermaid · error
The right-hand id [${rhsId}] does not yet exist. Please crea
Error message
The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it. What it means
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.
Source
Thrown at packages/mermaid/src/diagrams/architecture/architectureDb.ts:220
}: ArchitectureEdge): void {
if (!isArchitectureDirection(lhsDir)) {
throw new Error(
`Invalid direction given for left hand side of edge ${lhsId}--${rhsId}. Expected (L,R,T,B) got ${String(lhsDir)}`
);
}
if (!isArchitectureDirection(rhsDir)) {
throw new Error(
`Invalid direction given for right hand side of edge ${lhsId}--${rhsId}. Expected (L,R,T,B) got ${String(rhsDir)}`
);
}
if (!this.nodes.has(lhsId) && !this.groups.has(lhsId)) {
throw new Error(
`The left-hand id [${lhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
);
}
if (!this.nodes.has(rhsId) && !this.groups.has(rhsId)) {
throw new Error(
`The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
);
}
const lhsGroupId = this.nodes.get(lhsId)!.in;
const rhsGroupId = this.nodes.get(rhsId)!.in;
if (lhsGroup && lhsGroupId && rhsGroupId && lhsGroupId == rhsGroupId) {
throw new Error(
`The left-hand id [${lhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups.`
);
}
if (rhsGroup && lhsGroupId && rhsGroupId && lhsGroupId == rhsGroupId) {
throw new Error(
`The right-hand id [${rhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups.`
);
}
const edge = {View on GitHub (pinned to d93e9c88c0)
Solutions
- Declare the right-hand service, junction, or group first.
- Verify the spelling and case of rhsId.
Example fix
// before
db.addEdge({ lhsId: 'a', rhsId: 'b', lhsDir: 'L', rhsDir: 'R' }); // 'b' not declared
// after
db.addService({ id: 'a' });
db.addService({ id: 'b' });
db.addEdge({ lhsId: 'a', rhsId: 'b', lhsDir: 'L', rhsDir: 'R' }); Defensive patterns
Strategy: validation
Validate before calling
function addEdgeSafe(db, e) {
const exists = (id) => db.getNode(id) !== null || db.getGroups().some(g => g.id === id);
if (!exists(e.rhsId)) {
throw new Error(`rhsId '${e.rhsId}' is not declared`);
}
db.addEdge(e);
} Prevention
- Ensure the right-hand endpoint is declared before addEdge.
- Validate both endpoint ids against the DB before constructing edges.
When it happens
Trigger: Calling db.addEdge({ lhsId: 'a', rhsId: 'ghost', lhsDir: 'L', rhsDir: 'R' }) where 'ghost' was never registered.
Common situations: Edge declared before the right-hand target exists; typo in rhs id; id from a stale/cleared DB.
Related errors
- The left-hand id [${lhsId}] does not yet exist. Please creat
- The service [${id}]'s parent does not exist. Please make sur
- The junction [${id}]'s parent does not exist. Please make su
- The group [${id}]'s parent does not exist. Please make sure
- Invalid direction given for left hand side of edge ${lhsId}-
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/9ebb53e0ed164aef.
Report an issue: GitHub.