mermaid-js/mermaid · error · Error

Branch not found for commit ${commit.id}

Error message

Branch not found for commit ${commit.id}

What it means

Error "Branch not found for commit ${commit.id}" thrown in mermaid-js/mermaid.

Source

Thrown at packages/mermaid/src/diagrams/git/gitGraphRenderer.ts:206

  }

  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) {
    throw new Error(`Branch not found for commit ${commit.id}`);
  }

  const x = branch.pos;
  const y = curPos + LAYOUT_OFFSET;
  commitPos.set(commit.id, { x, y });
  return { x, y };
};

const setRootPosition = (commit: Commit, curPos: number, defaultPos: number) => {
  const branch = branchPos.get(commit.branch);
  if (!branch) {
    throw new Error(`Branch not found for commit ${commit.id}`);
  }

  const y = curPos + defaultPos;
  const x = branch.pos;
  commitPos.set(commit.id, { x, y });
};

View on GitHub (pinned to d93e9c88c0)

When it happens

Trigger: Thrown at packages/mermaid/src/diagrams/git/gitGraphRenderer.ts:206 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/68efbcb549ac6267. Report an issue: GitHub.