{"record":{"id":"c493591758f1408a","repo":"iOfficeAI/OfficeCLI","slug":"diagram-type-kind-is-not-supported-yet-curren","errorCode":null,"errorMessage":"diagram type '{kind}' is not supported yet (currently: flowchart, sequenceDiagram).","messagePattern":"diagram type '(.+?)' is not supported yet \\(currently: flowchart, sequenceDiagram\\)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Diagram/DiagramCompiler.cs","lineNumber":33,"sourceCode":"/// </summary>\npublic static class DiagramCompiler\n{\n    public static LaidOutGraph Compile(string mermaid)\n    {\n        var header = FirstMeaningfulLine(mermaid);\n\n        if (Regex.IsMatch(header, @\"^(flowchart|graph)\\b\", RegexOptions.IgnoreCase))\n            return FlowchartLayout.Layout(MermaidParser.Parse(mermaid));\n\n        if (Regex.IsMatch(header, @\"^sequenceDiagram\\b\", RegexOptions.IgnoreCase))\n            return SequenceLayout.Layout(SequenceLayout.Parse(mermaid));\n\n        // No explicit header → assume flowchart (mermaid's own lenient default).\n        if (header.Length == 0 || !Regex.IsMatch(header, @\"^[A-Za-z]\"))\n            return FlowchartLayout.Layout(MermaidParser.Parse(mermaid));\n\n        var kind = Regex.Match(header, @\"^[A-Za-z]+\").Value;\n        throw new ArgumentException(\n            $\"diagram type '{kind}' is not supported yet (currently: flowchart, sequenceDiagram).\");\n    }\n\n    private static string FirstMeaningfulLine(string text)\n    {\n        foreach (var raw in text.Split('\\n'))\n        {\n            var s = raw.Trim();\n            if (s.Length > 0 && !s.StartsWith(\"%%\"))\n                return s;\n        }\n        return \"\";\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":48,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Diagram/DiagramCompiler.cs#L15-L48","documentation":"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.","triggerScenarios":"Compiling a mermaid source whose header is 'classDiagram', 'stateDiagram', 'gantt', 'pie', 'erDiagram', 'gitGraph', 'mindmap', or any other unsupported mermaid type via the native synthesizer.","commonSituations":"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.","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."],"exampleFix":"// before\n(mermaid source)\nclassDiagram\n  Animal <|-- Dog\n// after — use render=image for unsupported types, or switch to flowchart:\n(mermaid source, render=image)\nclassDiagram\n  Animal <|-- Dog","handlingStrategy":"validation","validationCode":"static readonly Regex SupportedDiagramHeader = new(@\"^(flowchart|graph|sequenceDiagram)\\b\", RegexOptions.IgnoreCase);\nstatic string ValidateDiagramHeader(string mermaid)\n{\n    var first = mermaid.Split('\\n').Select(l => l.Trim()).FirstOrDefault(l => l.Length > 0 && !l.StartsWith(\"%%\")) ?? \"\";\n    if (first.Length == 0 || !Regex.IsMatch(first, @\"^[A-Za-z]\")) return mermaid; // defaults to flowchart\n    return SupportedDiagramHeader.IsMatch(first) ? mermaid : throw new ArgumentException($\"unsupported diagram type: {Regex.Match(first, @\"^[A-Za-z]+\").Value}\");\n}","typeGuard":"static bool IsSupportedDiagramType(string mermaid)\n{\n    var first = mermaid.Split('\\n').Select(l => l.Trim()).FirstOrDefault(l => l.Length > 0 && !l.StartsWith(\"%%\")) ?? \"\";\n    return first.Length == 0 || !Regex.IsMatch(first, @\"^[A-Za-z]\") || SupportedDiagramHeader.IsMatch(first);\n}","tryCatchPattern":"try { DiagramCompiler.Compile(mermaid); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"is not supported yet\"))\n{ /* switch to render=image for the unsupported type, or use flowchart/sequenceDiagram */ }","preventionTips":["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."],"tags":["diagram","mermaid","validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}