Why this happens
Every Mermaid document must open with a diagram type keyword -- flowchart, sequenceDiagram, classDiagram, stateDiagram-v2, erDiagram, gantt, pie, journey, and so on. Without one, Mermaid has no grammar to parse the rest of the text against.
This also happens when the keyword is misspelled, or when leftover prose or markdown formatting (like a stray ``` fence) ends up inside the Mermaid code block.
How to fix it
Add the correct diagram keyword as the very first non-comment line. Check spelling and capitalization -- sequenceDiagram is camelCase, stateDiagram-v2 needs the version suffix.
If you copied the snippet from a markdown file, make sure the ```mermaid fence itself isn't included inside the source you're rendering.