mermaid-js/mermaid · error
The service [${id}]'s parent does not exist. Please make sur
Error message
The service [${id}]'s parent does not exist. Please make sure the parent is created before this service What it means
Thrown by addService when a parent ('in') is specified but that parent id is not present in registeredIds. Architecture requires parents to be declared first (typically a group), so a forward reference or a typo'd parent id is rejected.
Source
Thrown at packages/mermaid/src/diagrams/architecture/architectureDb.ts:92
public addService({
id,
icon,
in: parent,
title,
iconText,
}: Omit<ArchitectureService, 'edges'>): void {
if (this.registeredIds.has(id)) {
throw new Error(
`The service id [${id}] is already in use by another ${this.registeredIds.get(id)}`
);
}
if (parent !== undefined) {
if (id === parent) {
throw new Error(`The service [${id}] cannot be placed within itself`);
}
if (!this.registeredIds.has(parent)) {
throw new Error(
`The service [${id}]'s parent does not exist. Please make sure the parent is created before this service`
);
}
if (this.registeredIds.get(parent) === 'node') {
throw new Error(`The service [${id}]'s parent is not a group`);
}
}
this.registeredIds.set(id, 'node');
this.nodes.set(id, {
id,
type: 'service',
icon,
iconText,
title,
edges: [],
in: parent,View on GitHub (pinned to d93e9c88c0)
Solutions
- Declare the parent group before the service that uses it.
- Verify the parent id spelling and case against the registered group id.
- If parentless, omit the 'in' field.
Example fix
// before
db.addService({ id: 'svc', in: 'grp' }); // grp not yet defined
// after
db.addGroup({ id: 'grp' });
db.addService({ id: 'svc', in: 'grp' }); Defensive patterns
Strategy: validation
Validate before calling
if (parent && db.getNode(parent) === null) {
throw new Error(`Parent '${parent}' not declared`);
}
db.addService({ id, in: parent }); Prevention
- Declare groups before services that nest in them.
- Sort architecture declarations parent-first before insertion.
- Validate parent id spelling and case.
When it happens
Trigger: addService({ id: 'svc', in: 'missing' }) where 'missing' was never added; declaring a child before its parent group.
Common situations: User writes a service inside a group that is defined later in the text, or the parent's id has a typo/case mismatch.
Related errors
- The junction [${id}]'s parent does not exist. Please make su
- The service [${id}] cannot be placed within itself
- The service [${id}]'s parent is not a group
- The junction [${id}]'s parent is not a group
- The service id [${id}] is already in use by another ${this.r
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/5f9c3f0c9fa3a84a.
Report an issue: GitHub.