#8287·mermaid

eventmodeling: a repeated frame id is accepted and redirects the later frame's relation to the first frame

Author: TomasEkeliCreated Sep 22, 2026Updated Sep 28, 2026
LabelsStatus: Approvedv12.0.1Graph: EventModeling

Description

Frame ids in eventmodeling are documented as unique, but nothing enforces that. When two frames share an id, the renderer places the second frame's box correctly but draws the relation it computed for that frame into the first frame. The result is a plausible-looking diagram with a wrong arrow and a box that appears unconnected.

Steps to reproduce

eventmodeling

tf 01 ui A
tf 02 cmd B
tf 01 evt C

Expected: A -> B -> C, or a parse or validation error on the second 01.

Actual: A -> B and B -> A. C is drawn with no relation.

Screenshots

GitHub's own mermaid renders the diagram type, so this is the same source, rendered live (it will look right once the bug is fixed):

mermaid
eventmodeling

tf 01 ui A
tf 02 cmd B
tf 01 evt C

Code Sample

The cause is in packages/mermaid/src/diagrams/eventmodeling/db.ts.

findBoxByFrame resolves a frame to a box by name and takes the first match:

typescript
function findBoxByFrame(boxes: Box[], frame: EmFrame | undefined): Box | undefined {
  ...
  return boxes.find((box) => box.frame.name === frame.name);
}

decidePositionRelation uses it to find the target of the relation being computed for the current frame:

typescript
const targetBox = findBoxByFrame(state.boxes, command.frame);

For the third line above, command.frame.name is 01, so targetBox is A. The source is then found by walking back from the previous line to the first box in a lane other than A's lane, which is B. So the relation for C becomes B -> A.

The same lookup serves ->>, note and gwt, so an explicit reference to a duplicated id also resolves to the first frame that has it.

Setup

  • mermaid 11.17.2 via @mermaid-js/mermaid-cli
  • also reproduced against develop, db.ts as of 2026-09-22

Suggested Solutions

Reject the duplicate in packages/parser/src/language/eventmodeling/event-modeling-validator.ts. The validator already checks the types of ->> sources per frame. A check over EventModel that collects frames[].name into a set and reports the second and later occurrences would make this a parse-time error with a location.

Independently, decidePositionRelation could take the target box by line index (state.boxes[command.index]), since the box for the current frame was positioned in the same pass. The name lookup then serves explicit references only.

Additional Context

The docs say the ids need only be unique, and compare them to BASIC line numbers. Because nothing enforces uniqueness, and because the numbers do not affect position, a reference that is not renumbered after an insert points at whatever frame now holds that number, with no error. The validation makes that failure loud.