iOfficeAI/OfficeCLI · error · ArgumentException
diagram type '{kind}' is not supported yet (currently: flowc
Error message
diagram type '{kind}' is not supported yet (currently: flowchart, sequenceDiagram). What it means
Thrown by DiagramCompiler.Compile (DiagramCompiler.cs:33) when the first meaningful line of the mermaid source starts with a letter (so it is not treated as a bare/empty flowchart default) but does not match flowchart/graph or sequenceDiagram headers. Only flowchart and sequenceDiagram have native layout engines; the 'diagram' umbrella name rejects unsupported types with a clear message rather than producing garbage.
Source
Thrown at src/officecli/Core/Diagram/DiagramCompiler.cs:33
/// </summary>
public static class DiagramCompiler
{
public static LaidOutGraph Compile(string mermaid)
{
var header = FirstMeaningfulLine(mermaid);
if (Regex.IsMatch(header, @"^(flowchart|graph)\b", RegexOptions.IgnoreCase))
return FlowchartLayout.Layout(MermaidParser.Parse(mermaid));
if (Regex.IsMatch(header, @"^sequenceDiagram\b", RegexOptions.IgnoreCase))
return SequenceLayout.Layout(SequenceLayout.Parse(mermaid));
// No explicit header → assume flowchart (mermaid's own lenient default).
if (header.Length == 0 || !Regex.IsMatch(header, @"^[A-Za-z]"))
return FlowchartLayout.Layout(MermaidParser.Parse(mermaid));
var kind = Regex.Match(header, @"^[A-Za-z]+").Value;
throw new ArgumentException(
$"diagram type '{kind}' is not supported yet (currently: flowchart, sequenceDiagram).");
}
private static string FirstMeaningfulLine(string text)
{
foreach (var raw in text.Split('\n'))
{
var s = raw.Trim();
if (s.Length > 0 && !s.StartsWith("%%"))
return s;
}
return "";
}
}
View on GitHub (pinned to 1ced45e900)
Solutions
- Restrict the native synthesizer to flowchart or sequenceDiagram sources.
- For other mermaid types (class, state, gantt, pie, er, git, mindmap), use render=image so the real mermaid.js renders a PNG via mmdc or a chrome-family browser.
- Add an explicit 'flowchart TD' header if the source is meant to be a flowchart.
Example fix
// before (mermaid source) classDiagram Animal <|-- Dog // after — use render=image for unsupported types, or switch to flowchart: (mermaid source, render=image) classDiagram Animal <|-- Dog
Defensive patterns
Strategy: validation
Validate before calling
static readonly Regex SupportedDiagramHeader = new(@"^(flowchart|graph|sequenceDiagram)\b", RegexOptions.IgnoreCase);
static string ValidateDiagramHeader(string mermaid)
{
var first = mermaid.Split('\n').Select(l => l.Trim()).FirstOrDefault(l => l.Length > 0 && !l.StartsWith("%%")) ?? "";
if (first.Length == 0 || !Regex.IsMatch(first, @"^[A-Za-z]")) return mermaid; // defaults to flowchart
return SupportedDiagramHeader.IsMatch(first) ? mermaid : throw new ArgumentException($"unsupported diagram type: {Regex.Match(first, @"^[A-Za-z]+").Value}");
} Type guard
static bool IsSupportedDiagramType(string mermaid)
{
var first = mermaid.Split('\n').Select(l => l.Trim()).FirstOrDefault(l => l.Length > 0 && !l.StartsWith("%%")) ?? "";
return first.Length == 0 || !Regex.IsMatch(first, @"^[A-Za-z]") || SupportedDiagramHeader.IsMatch(first);
} Try / catch
try { DiagramCompiler.Compile(mermaid); }
catch (ArgumentException ex) when (ex.Message.Contains("is not supported yet"))
{ /* switch to render=image for the unsupported type, or use flowchart/sequenceDiagram */ } Prevention
- Use render=image (mmdc/chrome) for class/state/gantt/pie/er/git/mindmap diagrams.
- Add an explicit 'flowchart TD' header if the source is meant to be a flowchart.
- Sniff the first meaningful line before compiling to choose native vs image rendering.
When it happens
Trigger: Compiling a mermaid source whose header is 'classDiagram', 'stateDiagram', 'gantt', 'pie', 'erDiagram', 'gitGraph', 'mindmap', or any other unsupported mermaid type via the native synthesizer.
Common situations: Pasting a class/state/ER diagram expecting native shapes; the native synthesizer only covers flowchart and sequenceDiagram, so other types need render=image (mmdc/chrome) instead of the built-in layout.
Related errors
- diagram has no nodes — the mermaid source has no node/edge s
- unknown diagram theme '{theme}'. Valid: {string.Join(", ", T
- unknown diagram layout '{layout}'. Valid: {string.Join(", ",
- unknown diagram look '{look}'. Valid: classic, handDrawn.
- failed to start mmdc.
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/c493591758f1408a.
Report an issue: GitHub.