mermaid-js/mermaid · error · Error
Closest parent not found for commit ${commit.id}
Error message
Closest parent not found for commit ${commit.id} What it means
Error "Closest parent not found for commit ${commit.id}" thrown in mermaid-js/mermaid.
Source
Thrown at packages/mermaid/src/diagrams/git/gitGraphRenderer.ts:187
const commit = commits.get(key);
if (commit?.parents.length) {
const closestParent = findClosestParentBT(commit.parents)!;
curPos = commitPos.get(closestParent)!.y - COMMIT_STEP;
if (curPos <= maxPosition) {
maxPosition = curPos;
}
const x = branchPos.get(commit.branch)!.pos;
const y = curPos - LAYOUT_OFFSET;
commitPos.set(commit.id, { x: x, y: y });
}
});
};
const findClosestParentPos = (commit: Commit): number => {
const closestParent = findClosestParent(commit.parents.filter((p) => p !== null));
if (!closestParent) {
throw new Error(`Closest parent not found for commit ${commit.id}`);
}
const closestParentPos = commitPos.get(closestParent)?.y;
if (closestParentPos === undefined) {
throw new Error(`Closest parent position not found for commit ${commit.id}`);
}
return closestParentPos;
};
const calculateCommitPosition = (commit: Commit): number => {
const closestParentPos = findClosestParentPos(commit);
return closestParentPos + COMMIT_STEP;
};
const setCommitPosition = (commit: Commit, curPos: number): CommitPosition => {
const branch = branchPos.get(commit.branch);
if (!branch) {View on GitHub (pinned to d93e9c88c0)
When it happens
Trigger: Thrown at packages/mermaid/src/diagrams/git/gitGraphRenderer.ts:187 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/0ed94bec2de73869.
Report an issue: GitHub.