iOfficeAI/OfficeCLI · error · ArgumentException
unknown diagram look '{look}'. Valid: classic, handDrawn.
Error message
unknown diagram look '{look}'. Valid: classic, handDrawn. What it means
Thrown by MermaidImageRenderer.ComposeSource (MermaidImageRenderer.cs:136) when a non-null look value is not in the accepted Looks set {classic, handDrawn} (case-insensitive). 'look' is mermaid 11's rendering style option; handDrawn produces a sketch-like appearance. The canonical camelCase spelling 'handDrawn' is normalized at injection time, but the accepted input set uses lowercase comparison.
Source
Thrown at src/officecli/Core/Diagram/MermaidImageRenderer.cs:136
/// source unchanged when no option is set. Rejects unknown values with a
/// message listing the valid ones. When the source already carries its own
/// frontmatter or an <c>%%{init}%%</c> directive, the source wins and the
/// options are ignored (caller may warn) — merging into an existing block is
/// out of scope and would risk producing a malformed document.
/// </summary>
public static string ComposeSource(string mermaid, string? theme, string? layout, string? look)
{
theme = string.IsNullOrWhiteSpace(theme) ? null : theme.Trim();
layout = string.IsNullOrWhiteSpace(layout) ? null : layout.Trim();
look = string.IsNullOrWhiteSpace(look) ? null : look.Trim();
if (theme == null && layout == null && look == null) return mermaid;
if (theme != null && !Themes.Contains(theme))
throw new ArgumentException($"unknown diagram theme '{theme}'. Valid: {string.Join(", ", Themes)}.");
if (layout != null && !Layouts.Contains(layout))
throw new ArgumentException($"unknown diagram layout '{layout}'. Valid: {string.Join(", ", Layouts)}.");
if (look != null && !Looks.Contains(look))
throw new ArgumentException($"unknown diagram look '{look}'. Valid: classic, handDrawn.");
var lead = mermaid.TrimStart();
if (lead.StartsWith("---", StringComparison.Ordinal) || lead.StartsWith("%%{", StringComparison.Ordinal))
return mermaid; // source already declares config — do not double-inject
var sb = new StringBuilder("---\nconfig:\n");
if (theme != null) sb.Append(" theme: ").Append(theme.ToLowerInvariant()).Append('\n');
if (layout != null) sb.Append(" layout: ").Append(layout.ToLowerInvariant()).Append('\n');
// look's canonical mermaid spelling is camelCase handDrawn; normalize.
if (look != null)
sb.Append(" look: ")
.Append(look.Equals("handdrawn", StringComparison.OrdinalIgnoreCase) ? "handDrawn" : "classic")
.Append('\n');
sb.Append("---\n").Append(mermaid);
return sb.ToString();
}
/// <summary>True when the (already composed) source carries a style frontmatter,View on GitHub (pinned to 1ced45e900)
Solutions
- Use one of: classic or handDrawn.
- Leave look unset to keep the default classic appearance.
Example fix
// before look=sketch // after look=handDrawn
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> ValidLooks = new(StringComparer.OrdinalIgnoreCase) { "classic","handdrawn" };
static string ValidateLook(string look) => ValidLooks.Contains(look ?? "") ? look : throw new ArgumentException($"unknown look '{look}'"); Type guard
static bool IsValidLook(string look) => ValidLooks.Contains(look ?? "");
Try / catch
try { MermaidImageRenderer.ComposeSource(mermaid, null, null, look); }
catch (ArgumentException ex) when (ex.Message.Contains("unknown diagram look"))
{ /* default to null (classic) or pick classic/handDrawn */ } Prevention
- Use 'handDrawn' (case-insensitive) for the sketch style, not 'sketch'/'rough'.
- Leave look null for the default classic appearance.
- Remember 'look' is a mermaid 11 option; it does not exist in v10 themes.
When it happens
Trigger: Setting a diagram look to 'sketch', 'rough', 'neon', 'hand', or any value outside {classic, handDrawn}.
Common situations: Guessing 'sketch' or 'rough' (mermaid uses 'handDrawn'); passing 'handdrawn' works (case-insensitive) but 'hand-drawn' does not; expecting a mermaid 10 theme that does not exist under the look option in v11.
Related errors
- diagram type '{kind}' is not supported yet (currently: flowc
- 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(", ",
- failed to start mmdc.
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/5f1bc22ce6480a4e.
Report an issue: GitHub.