mermaid-js/mermaid · error
The group [${id}]'s parent is not a group
Error message
The group [${id}]'s parent is not a group What it means
Thrown by ArchitectureDB.addGroup when the `in` (parent) field resolves to an id registered as a 'node' (a service or junction) rather than a 'group'. Only groups may contain other groups; services and junctions are leaf nodes and cannot be parents. The registeredIds map distinguishes the two kinds, and this check enforces the type constraint.
Source
Thrown at packages/mermaid/src/diagrams/architecture/architectureDb.ts:176
}
public addGroup({ id, icon, in: parent, title }: ArchitectureGroup): void {
if (this.registeredIds.has(id)) {
throw new Error(
`The group id [${id}] is already in use by another ${this.registeredIds.get(id)}`
);
}
if (parent !== undefined) {
if (id === parent) {
throw new Error(`The group [${id}] cannot be placed within itself`);
}
if (!this.registeredIds.has(parent)) {
throw new Error(
`The group [${id}]'s parent does not exist. Please make sure the parent is created before this group`
);
}
if (this.registeredIds.get(parent) === 'node') {
throw new Error(`The group [${id}]'s parent is not a group`);
}
}
this.registeredIds.set(id, 'group');
this.groups.set(id, {
id,
icon,
title,
in: parent,
});
}
public getGroups(): ArchitectureGroup[] {
return [...this.groups.values()];
}
public addEdge({
lhsId,
rhsId,View on GitHub (pinned to d93e9c88c0)
Solutions
- Point `in` at an id that was registered as a group (via addGroup).
- If you intended the service to be a container, restructure — services cannot hold groups; promote it to a group instead.
Example fix
// before
db.addService({ id: 'svc1' });
db.addGroup({ id: 'g', in: 'svc1' }); // svc1 is a node, not a group
// after
db.addGroup({ id: 'outer' });
db.addGroup({ id: 'g', in: 'outer' }); Defensive patterns
Strategy: validation
Validate before calling
function addGroupSafe(db, g) {
if (g.in !== undefined) {
const parentIsGroup = db.getGroups().some(gr => gr.id === g.in);
const parentIsNode = db.getNodes().some(n => n.id === g.in);
if (parentIsNode && !parentIsGroup) {
throw new Error(`Parent '${g.in}' is a node, not a group`);
}
}
db.addGroup(g);
} Prevention
- Only nest groups under other groups.
- When refactoring, re-check that `in` does not point at a service or junction.
When it happens
Trigger: Calling db.addGroup({ id: 'g', in: 'svc1' }) where 'svc1' was previously registered via addService or addJunction (registered as 'node').
Common situations: Confusing a service name with a group name when writing containment; typos where a group id collides with a service id; restructuring that moves groups under services.
Related errors
- The group [${id}] cannot be placed within itself
- The group [${id}]'s parent does not exist. Please make sure
- The service [${id}]'s parent is not a group
- The junction [${id}]'s parent is not a group
- The group id [${id}] is already in use by another ${this.reg
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/5fde511f211b8a7f.
Report an issue: GitHub.