mermaid-js/mermaid · error
align ${hint.direction} lists [${id}] more than once
Error message
align ${hint.direction} lists [${id}] more than once What it means
Thrown by ArchitectureDB.addLayoutHint when the same id appears more than once in hint.members. The DB walks the members array with a `seen` Set and rejects any repeat. An align chain with a duplicated node would create a degenerate (zero-length) constraint and confuse the layout engine.
Source
Thrown at packages/mermaid/src/diagrams/architecture/architectureDb.ts:277
public getEdges(): ArchitectureEdge[] {
return this.edges;
}
public addLayoutHint(hint: ArchitectureLayoutHint): void {
if (hint.members.length < 2) {
throw new Error(
`An align directive requires at least two members; got ${hint.members.length}`
);
}
const seen = new Set<string>();
hint.members.forEach((id) => {
if (this.registeredIds.get(id) !== 'node') {
throw new Error(
`align ${hint.direction} references [${id}], which is not a service or junction`
);
}
if (seen.has(id)) {
throw new Error(`align ${hint.direction} lists [${id}] more than once`);
}
seen.add(id);
});
this.layoutHints.push(hint);
}
public getLayoutHints(): ArchitectureLayoutHint[] {
return this.layoutHints;
}
/**
* Returns the current diagram's adjacency list, spatial map, & group alignments.
* If they have not been created, run the algorithms to generate them.
* @returns
*/
public getDataStructures() {
if (this.dataStructures === undefined) {
// Tracks how groups are aligned with one another. Generated while creating the adj listView on GitHub (pinned to d93e9c88c0)
Solutions
- Remove duplicate ids so each member appears exactly once.
- Dedupe the members array before calling addLayoutHint.
Example fix
// before
db.addLayoutHint({ direction: 'row', members: ['a', 'a', 'b'] });
// after
db.addLayoutHint({ direction: 'row', members: ['a', 'b'] }); Defensive patterns
Strategy: validation
Validate before calling
function addLayoutHintSafe(db, hint) {
if (new Set(hint.members).size !== hint.members.length) {
throw new Error('align members contains duplicates');
}
db.addLayoutHint(hint);
} Type guard
const hasNoDuplicates = (arr) => new Set(arr).size === arr.length;
Prevention
- Dedupe the members array before calling addLayoutHint.
- Avoid merging align chains by simple concatenation.
When it happens
Trigger: Calling db.addLayoutHint({ direction: 'row', members: ['a', 'a', 'b'] }). In DSL: `align row: a, a, b`.
Common situations: Copy-paste duplication in a DSL align chain; programmatic array construction that concatenates lists without dedup; refactors that merge two align directives naively.
Related errors
- An align directive requires at least two members; got ${hint
- align ${hint.direction} references [${id}], which is not a s
- Architecture layout failed: a declared `align row|column` di
- No nodes found in layout data
- No nodes available to create tree
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/7da669a73f08fbca.
Report an issue: GitHub.