mermaid-js/mermaid · error · Error
The index ${pos} for linkStyle is out of bounds. Valid indic
Error message
The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length - 1}. (Help: Ensure that the index is within the range of existing edges.) What it means
Error "The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length - 1}. (Help: Ensure that the index is within the range of existing edges.)" thrown in mermaid-js/mermaid.
Source
Thrown at packages/mermaid/src/diagrams/flowchart/flowDb.ts:394
*/
public updateLinkInterpolate(positions: ('default' | number)[], interpolate: string) {
positions.forEach((pos) => {
if (pos === 'default') {
this.edges.defaultInterpolate = interpolate;
} else {
this.edges[pos].interpolate = interpolate;
}
});
}
/**
* Updates a link with a style
*
*/
public updateLink(positions: ('default' | number)[], style: string[]) {
positions.forEach((pos) => {
if (typeof pos === 'number' && pos >= this.edges.length) {
throw new Error(
`The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${
this.edges.length - 1
}. (Help: Ensure that the index is within the range of existing edges.)`
);
}
if (pos === 'default') {
this.edges.defaultStyle = style;
} else {
this.edges[pos].style = style;
// if edges[pos].style does have fill not set, set it to none
if (
(this.edges[pos]?.style?.length ?? 0) > 0 &&
!this.edges[pos]?.style?.some((s) => s?.startsWith('fill'))
) {
this.edges[pos]?.style?.push('fill:none');
}
}
});View on GitHub (pinned to d93e9c88c0)
When it happens
Trigger: Thrown at packages/mermaid/src/diagrams/flowchart/flowDb.ts:394 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/856cd2be07127146.
Report an issue: GitHub.