{"record":{"id":"a978bf3576b70641","repo":"mermaid-js/mermaid","slug":"align-hint-direction-references-id-which","errorCode":null,"errorMessage":"align ${hint.direction} references [${id}], which is not a service or junction","messagePattern":"align (.+?) references \\[(.+?)\\], which is not a service or junction","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/architecture/architectureDb.ts","lineNumber":272,"sourceCode":"      lhsNode.edges.push(this.edges[this.edges.length - 1]);\n      rhsNode.edges.push(this.edges[this.edges.length - 1]);\n    }\n  }\n\n  public getEdges(): ArchitectureEdge[] {\n    return this.edges;\n  }\n\n  public addLayoutHint(hint: ArchitectureLayoutHint): void {\n    if (hint.members.length < 2) {\n      throw new Error(\n        `An align directive requires at least two members; got ${hint.members.length}`\n      );\n    }\n    const seen = new Set<string>();\n    hint.members.forEach((id) => {\n      if (this.registeredIds.get(id) !== 'node') {\n        throw new Error(\n          `align ${hint.direction} references [${id}], which is not a service or junction`\n        );\n      }\n      if (seen.has(id)) {\n        throw new Error(`align ${hint.direction} lists [${id}] more than once`);\n      }\n      seen.add(id);\n    });\n    this.layoutHints.push(hint);\n  }\n\n  public getLayoutHints(): ArchitectureLayoutHint[] {\n    return this.layoutHints;\n  }\n\n  /**\n   * Returns the current diagram's adjacency list, spatial map, & group alignments.\n   * If they have not been created, run the algorithms to generate them.","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/architecture/architectureDb.ts#L254-L290","documentation":"Thrown by ArchitectureDB.addLayoutHint when a member id is not registered as a 'node' (i.e. not a service or junction). The registeredIds map must contain the id with value 'node'; groups (registered as 'group') and unknown ids both fail this check. Align directives operate on services and junctions only — groups cannot be aligned.","triggerScenarios":"Calling db.addLayoutHint({ direction: 'row', members: ['groupA', 'svc1'] }) where 'groupA' is a group; or members: ['unknown'] where the id was never declared.","commonSituations":"Referencing a group id in an align directive by mistake; typo in a member id; referencing a junction before it is declared.","solutions":["Reference only ids declared via addService or addJunction.","Verify every member id is spelled correctly and was declared before addLayoutHint is called."],"exampleFix":"// before\ndb.addGroup({ id: 'grp' });\ndb.addService({ id: 'svc' });\ndb.addLayoutHint({ direction: 'row', members: ['grp', 'svc'] }); // 'grp' is a group\n// after\ndb.addService({ id: 'svc2' });\ndb.addLayoutHint({ direction: 'row', members: ['svc', 'svc2'] });","handlingStrategy":"validation","validationCode":"function addLayoutHintSafe(db, hint) {\n  for (const id of hint.members) {\n    const node = db.getNode(id);\n    if (!node) {\n      throw new Error(`align member '${id}' is not a declared service/junction`);\n    }\n  }\n  db.addLayoutHint(hint);\n}","typeGuard":"const isAlignableNode = (db, id) => db.getNode(id) !== null;","tryCatchPattern":null,"preventionTips":["Only reference service/junction ids in align directives.","Declare all nodes before issuing layout hints."],"tags":["architecture","layout","align","type-mismatch"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}