mermaid-js/mermaid · error
The group id [${id}] is already in use by another ${this.reg
Error message
The group id [${id}] is already in use by another ${this.registeredIds.get(id)} What it means
Thrown by addGroup when the group id already exists in registeredIds. Groups share the id namespace with services and junctions, so a collision with any prior entity trips this; the suffix ('node' or 'group') indicates the prior owner type.
Source
Thrown at packages/mermaid/src/diagrams/architecture/architectureDb.ts:162
in: parent,
});
}
public getJunctions(): ArchitectureJunction[] {
return [...this.nodes.values()].filter(isArchitectureJunction);
}
public getNodes(): ArchitectureNode[] {
return [...this.nodes.values()];
}
public getNode(id: string): ArchitectureNode | null {
return this.nodes.get(id) ?? null;
}
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');View on GitHub (pinned to d93e9c88c0)
Solutions
- Give each group a unique id; namespace if labels repeat.
- Check db.getGroups()/registeredIds before adding.
- If a clash is intentional, rename one entity and keep the title for display.
Example fix
// before
db.addGroup({ id: 'net' });
db.addGroup({ id: 'net' }); // throws
// after
db.addGroup({ id: 'net1', title: 'net' });
db.addGroup({ id: 'net2', title: 'net' }); Defensive patterns
Strategy: validation
Validate before calling
if (db.getGroups().some((g) => g.id === id) || db.getNode(id) !== null) {
throw new Error(`id '${id}' already in use`);
}
db.addGroup({ id }); Type guard
function isGroupIdFree(db: ArchitectureDB, id: string): boolean {
return db.getNode(id) === null && !db.getGroups().some((g) => g.id === id);
} Prevention
- Check both nodes and groups for the id before addGroup.
- Namespace group ids to avoid collisions with services/junctions.
- Dedupe ids in any spec generator before insertion.
When it happens
Trigger: addGroup with an id already used by another group, a service, or a junction; defining two groups with the same id.
Common situations: Duplicate group labels in user text, generated specs with non-unique group ids, or a group id reused as a service id.
Related errors
- The service id [${id}] is already in use by another ${this.r
- The service [${id}]'s parent is not a group
- The junction id [${id}] is already in use by another ${this.
- The junction [${id}]'s parent is not a group
- The service [${id}] cannot be placed within itself
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/d1fa370d31ac4b08.
Report an issue: GitHub.