{"record":{"id":"1513f2501f674d62","repo":"iOfficeAI/OfficeCLI","slug":"unknown-diagram-theme-theme-valid-string-jo","errorCode":null,"errorMessage":"unknown diagram theme '{theme}'. Valid: {string.Join(\", \", Themes)}.","messagePattern":"unknown diagram theme '(.+?)'\\. Valid: (.+?)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Diagram/MermaidImageRenderer.cs","lineNumber":132,"sourceCode":"    /// <summary>\n    /// Bake the requested style options into the mermaid source as a leading\n    /// <c>--- config: … ---</c> frontmatter block, so they render AND round-trip\n    /// (the composed source is what gets stamped into alt-text). Returns the\n    /// source unchanged when no option is set. Rejects unknown values with a\n    /// message listing the valid ones. When the source already carries its own\n    /// frontmatter or an <c>%%{init}%%</c> directive, the source wins and the\n    /// options are ignored (caller may warn) — merging into an existing block is\n    /// out of scope and would risk producing a malformed document.\n    /// </summary>\n    public static string ComposeSource(string mermaid, string? theme, string? layout, string? look)\n    {\n        theme = string.IsNullOrWhiteSpace(theme) ? null : theme.Trim();\n        layout = string.IsNullOrWhiteSpace(layout) ? null : layout.Trim();\n        look = string.IsNullOrWhiteSpace(look) ? null : look.Trim();\n        if (theme == null && layout == null && look == null) return mermaid;\n\n        if (theme != null && !Themes.Contains(theme))\n            throw new ArgumentException($\"unknown diagram theme '{theme}'. Valid: {string.Join(\", \", Themes)}.\");\n        if (layout != null && !Layouts.Contains(layout))\n            throw new ArgumentException($\"unknown diagram layout '{layout}'. Valid: {string.Join(\", \", Layouts)}.\");\n        if (look != null && !Looks.Contains(look))\n            throw new ArgumentException($\"unknown diagram look '{look}'. Valid: classic, handDrawn.\");\n\n        var lead = mermaid.TrimStart();\n        if (lead.StartsWith(\"---\", StringComparison.Ordinal) || lead.StartsWith(\"%%{\", StringComparison.Ordinal))\n            return mermaid; // source already declares config — do not double-inject\n\n        var sb = new StringBuilder(\"---\\nconfig:\\n\");\n        if (theme != null) sb.Append(\"  theme: \").Append(theme.ToLowerInvariant()).Append('\\n');\n        if (layout != null) sb.Append(\"  layout: \").Append(layout.ToLowerInvariant()).Append('\\n');\n        // look's canonical mermaid spelling is camelCase handDrawn; normalize.\n        if (look != null)\n            sb.Append(\"  look: \")\n              .Append(look.Equals(\"handdrawn\", StringComparison.OrdinalIgnoreCase) ? \"handDrawn\" : \"classic\")\n              .Append('\\n');\n        sb.Append(\"---\\n\").Append(mermaid);","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Diagram/MermaidImageRenderer.cs#L114-L150","documentation":"Thrown by MermaidImageRenderer.ComposeSource (MermaidImageRenderer.cs:132) when a non-null theme value is not in the accepted Themes set {default, dark, neutral, forest, base} (case-insensitive). ComposeSource bakes style options into a leading frontmatter block so they render and round-trip; unknown values are rejected before injection to avoid a malformed document. The set is kept in sync with schemas/help diagram documentation.","triggerScenarios":"Setting a diagram theme to 'light' (use 'default'), 'black', 'monochrome', 'ocean', or any value outside {default, dark, neutral, forest, base}.","commonSituations":"Guessing 'light' instead of 'default'; using a mermaid version-specific theme name not in this set; passing a hex color or custom theme object that this option does not accept.","solutions":["Use one of: default, dark, neutral, forest, base.","Leave the theme unset (null/empty) to use mermaid's built-in default."],"exampleFix":"// before\ntheme=light\n// after\ntheme=default","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> ValidThemes = new(StringComparer.OrdinalIgnoreCase) { \"default\",\"dark\",\"neutral\",\"forest\",\"base\" };\nstatic string ValidateTheme(string theme) => ValidThemes.Contains(theme ?? \"\") ? theme : throw new ArgumentException($\"unknown theme '{theme}'\");","typeGuard":"static bool IsValidTheme(string theme) => ValidThemes.Contains(theme ?? \"\");","tryCatchPattern":"try { MermaidImageRenderer.ComposeSource(mermaid, theme, null, null); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"unknown diagram theme\"))\n{ /* default to null theme or pick from {default,dark,neutral,forest,base} */ }","preventionTips":["Use 'default' instead of guessing 'light'.","Leave theme null/empty for mermaid's built-in default.","Keep the accepted set in sync with schemas/help diagram documentation."],"tags":["diagram","mermaid","theme","validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}