mermaid-js/mermaid · error
The right-hand id [${rhsId}] is modified to traverse the gro
Error message
The right-hand id [${rhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups. What it means
Thrown by ArchitectureDB.addEdge when rhsGroup is truthy but both endpoints share the same group (lhsGroupId === rhsGroupId). Mirror of the lhsGroup check: the rhsGroup flag means the edge crosses a group boundary on the RHS, which is impossible inside a single group. Fires only when both endpoints are nodes (services/junctions).
Source
Thrown at packages/mermaid/src/diagrams/architecture/architectureDb.ts:233
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 = {
lhsId,
lhsDir,
lhsInto,
lhsGroup,
rhsId,
rhsDir,
rhsInto,
rhsGroup,
title,
};
this.edges.push(edge);
const lhsNode = this.nodes.get(lhsId);View on GitHub (pinned to d93e9c88c0)
Solutions
- Remove rhsGroup when both endpoints are in the same group.
- If the edge should cross a boundary, ensure the two endpoints are in different groups.
Example fix
// before
db.addEdge({ lhsId: 'a', rhsId: 'b', lhsDir: 'L', rhsDir: 'R', rhsGroup: true }); // same group
// after
db.addEdge({ lhsId: 'a', rhsId: 'b', lhsDir: 'L', rhsDir: 'R' }); Defensive patterns
Strategy: validation
Validate before calling
function addEdgeSafe(db, e) {
const lhsNode = db.getNode(e.lhsId);
const rhsNode = db.getNode(e.rhsId);
if (e.rhsGroup && lhsNode && rhsNode && lhsNode.in && lhsNode.in === rhsNode.in) {
throw new Error('rhsGroup set but both endpoints share a group');
}
db.addEdge(e);
} Prevention
- Only set rhsGroup for genuine boundary-crossing edges.
- Re-validate group flags after any structural refactor of groups.
When it happens
Trigger: Two services in the same group connected by an edge with rhsGroup: true. e.g. addEdge({lhsId:'a', rhsId:'b', ..., rhsGroup:true}) with both 'a' and 'b' having the same `in` group.
Common situations: Copy-paste of edge flags; treating rhsGroup as a styling hint; edge originally between groups later refactored to be intra-group without dropping the flag.
Related errors
- The left-hand id [${lhsId}] is modified to traverse the grou
- Invalid direction given for left hand side of edge ${lhsId}-
- Invalid direction given for right hand side of edge ${lhsId}
- The service id [${id}] is already in use by another ${this.r
- The service [${id}] cannot be placed within itself
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/d97411ebd344908f.
Report an issue: GitHub.