{"record":{"id":"4c20615a7533b1a0","repo":"mermaid-js/mermaid","slug":"the-service-id-s-parent-is-not-a-group","errorCode":null,"errorMessage":"The service [${id}]'s parent is not a group","messagePattern":"The service \\[(.+?)\\]'s parent is not a group","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/architecture/architectureDb.ts","lineNumber":97,"sourceCode":"    title,\n    iconText,\n  }: Omit<ArchitectureService, 'edges'>): void {\n    if (this.registeredIds.has(id)) {\n      throw new Error(\n        `The service id [${id}] is already in use by another ${this.registeredIds.get(id)}`\n      );\n    }\n    if (parent !== undefined) {\n      if (id === parent) {\n        throw new Error(`The service [${id}] cannot be placed within itself`);\n      }\n      if (!this.registeredIds.has(parent)) {\n        throw new Error(\n          `The service [${id}]'s parent does not exist. Please make sure the parent is created before this service`\n        );\n      }\n      if (this.registeredIds.get(parent) === 'node') {\n        throw new Error(`The service [${id}]'s parent is not a group`);\n      }\n    }\n\n    this.registeredIds.set(id, 'node');\n\n    this.nodes.set(id, {\n      id,\n      type: 'service',\n      icon,\n      iconText,\n      title,\n      edges: [],\n      in: parent,\n    });\n  }\n\n  public getServices(): ArchitectureService[] {\n    return [...this.nodes.values()].filter(isArchitectureService);","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L79-L115","documentation":"Thrown by addService when the referenced parent exists in registeredIds but is tagged 'node' rather than 'group'. Only groups can contain services, so nesting a service under another service or a junction is rejected.","triggerScenarios":"addService({ id: 'b', in: 'a' }) where 'a' was previously added via addService or addJunction (both register as 'node').","commonSituations":"User nests one service inside another service instead of inside a group, or mistakes a junction for a container.","solutions":["Make the container a group: addGroup first, then nest the service under it.","If the intended parent is a service, flatten the hierarchy or wrap both in a group."],"exampleFix":"// before\ndb.addService({ id: 'parent' });\ndb.addService({ id: 'child', in: 'parent' }); // throws: parent is a node\n\n// after\ndb.addGroup({ id: 'parent' });\ndb.addService({ id: 'child', in: 'parent' });","handlingStrategy":"validation","validationCode":"if (parent) {\n  const p = db.getGroups().find((g) => g.id === parent);\n  if (!p) throw new Error(`'${parent}' is not a group; cannot nest`);\n}\ndb.addService({ id, in: parent });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only nest services under groups.","Expose a helper that resolves a group by id before adding children."],"tags":["architecture","mermaid","validation","parent","group"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}