mermaid-js/mermaid · error · Error
C4 shape "${fromNode.alias}" has no intersect function. Plea
Error message
C4 shape "${fromNode.alias}" has no intersect function. Please report this to https://github.com/mermaid-js/mermaid/issues What it means
Thrown by getIntersectPoint when a C4Shape has no `intersect` function. The intersect function is normally assigned to each c4Shape during drawC4ShapeArray pass 2 (c4Shape.intersect = node.intersect). If it is missing when drawRels later tries to compute edge endpoints, this error fires. The message itself directs users to file a bug, signalling this is considered an internal invariant violation rather than a user-input error.
Source
Thrown at packages/mermaid/src/diagrams/c4/c4Renderer.ts:345
currentBounds.bumpLastMargin(conf.c4ShapeMargin);
};
class Point {
x: number;
y: number;
constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
}
/*
* Get the intersection of the line between the center point of a rectangle and a point outside the rectangle.
*/
const getIntersectPoint = function (fromNode: C4Shape, endPoint: Point): Point | null {
if (!fromNode.intersect) {
throw new Error(
`C4 shape "${fromNode.alias}" has no intersect function. Please report this to https://github.com/mermaid-js/mermaid/issues`
);
}
const { x, y } = fromNode.intersect(endPoint);
return new Point(x, y);
};
const getIntersectPoints = function (fromNode: C4Shape, endNode: C4Shape) {
const endIntersectPoint = { x: 0, y: 0 };
endIntersectPoint.x = endNode.x + endNode.width / 2;
endIntersectPoint.y = endNode.y + endNode.height / 2;
const startPoint = getIntersectPoint(fromNode, endIntersectPoint);
endIntersectPoint.x = fromNode.x + fromNode.width / 2;
endIntersectPoint.y = fromNode.y + fromNode.height / 2;
const endPoint = getIntersectPoint(endNode, endIntersectPoint);
return { startPoint: startPoint, endPoint: endPoint };
};View on GitHub (pinned to d93e9c88c0)
Solutions
- Report the issue to https://github.com/mermaid-js/mermaid/issues as the message instructs, including the diagram that triggers it.
- Simplify the C4 diagram (fewer/custom shape variants) to isolate which shape lacks the intersect function.
- Upgrade mermaid — the missing intersect assignment may be fixed in a newer release.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await mermaid.render(id, c4DiagramText);
} catch (err) {
if (err instanceof Error && err.message.includes('has no intersect function')) {
// Internal invariant violation — report upstream and simplify the diagram.
}
throw err;
} Prevention
- Avoid exotic or custom C4 shapes that may not attach an intersect function.
- Keep mermaid current; this path is treated as a bug.
When it happens
Trigger: Calling drawRels on a C4Shape whose intersect was never set — e.g. because drawC4ShapeArray was skipped, errored mid-pass for that shape, or the underlying unified shape did not provide an intersect function.
Common situations: Internal bug where a shape handler in the registry does not attach an intersect function; partial render after an earlier shape threw; shape handler mismatch across versions.
Related errors
- C4: no shape handler for "${node.shape}"
- C4 rel "${rel.from}" -> "${rel.to}" references an unknown sh
- Could not calculate intersection points for rel "${rel.from}
- Layout data is required
AI-assisted analysis of mermaid-js/mermaid@d93e9c88c0 (2026-08-12).
Data as JSON: /api/errors/ee5fee0dd62b83ed.
Report an issue: GitHub.