mermaid-js/mermaid · error

The junction [${id}]'s parent is not a group

Error message

The junction [${id}]'s parent is not a group

What it means

Thrown by addJunction when the referenced parent exists but is tagged 'node' rather than 'group'. Only groups can contain junctions, so nesting a junction under a service or another junction is rejected.

Source

Thrown at packages/mermaid/src/diagrams/architecture/architectureDb.ts:134

  }

  public addJunction({ id, in: parent }: Omit<ArchitectureJunction, 'edges'>): void {
    if (this.registeredIds.has(id)) {
      throw new Error(
        `The junction id [${id}] is already in use by another ${this.registeredIds.get(id)}`
      );
    }
    if (parent !== undefined) {
      if (id === parent) {
        throw new Error(`The junction [${id}] cannot be placed within itself`);
      }
      if (!this.registeredIds.has(parent)) {
        throw new Error(
          `The junction [${id}]'s parent does not exist. Please make sure the parent is created before this junction`
        );
      }
      if (this.registeredIds.get(parent) === 'node') {
        throw new Error(`The junction [${id}]'s parent is not a group`);
      }
    }

    this.registeredIds.set(id, 'node');

    this.nodes.set(id, {
      id,
      type: 'junction',
      edges: [],
      in: parent,
    });
  }

  public getJunctions(): ArchitectureJunction[] {
    return [...this.nodes.values()].filter(isArchitectureJunction);
  }

  public getNodes(): ArchitectureNode[] {

View on GitHub (pinned to d93e9c88c0)

Solutions

  1. Put the junction inside a group: addGroup first, then addJunction with in:<groupId>.
  2. If the intended container is a node, wrap both in a group.

Example fix

// before
db.addService({ id: 'svc' });
db.addJunction({ id: 'j', in: 'svc' }); // throws

// after
db.addGroup({ id: 'box' });
db.addJunction({ id: 'j', in: 'box' });
Defensive patterns

Strategy: validation

Validate before calling

if (parent) {
  const isGroup = db.getGroups().some((g) => g.id === parent);
  if (!isGroup) throw new Error(`'${parent}' is not a group`);
}
db.addJunction({ id, in: parent });

Prevention

When it happens

Trigger: addJunction({ id: 'j', in: 'svc' }) where 'svc' was added via addService or addJunction (both 'node').

Common situations: User places a junction inside a service instead of a group, or chains junctions under each other.

Related errors


AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12). Data as JSON: /api/errors/7a177f4763df9d07. Report an issue: GitHub.