iOfficeAI/OfficeCLI · error · CliException
invalid_render
invalid_render
Error message
Invalid --render value: {renderMode}. Valid: auto, native, html What it means
The --render flag for 'view' screenshot mode accepts exactly auto, native, or html. 'auto' picks native on Windows-with-Word/PowerPoint and html elsewhere; 'native' forces OS-native (errors if unavailable); 'html' forces the browser path. Any other value is rejected with the valid set surfaced.
Source
Thrown at src/officecli/CommandBuilder.View.cs:81
var maxLines = result.GetValue(maxLinesOpt);
var issueType = IssueSubtypes.Validate(result.GetValue(issueTypeOpt));
var limit = result.GetValue(limitOpt);
var colsStr = result.GetValue(colsOpt);
var pageFilter = result.GetValue(pageOpt);
var browser = result.GetValue(browserOpt);
var outArg = result.GetValue(outOpt);
var clipArg = result.GetValue(clipOpt);
var screenshotWidth = result.GetValue(screenshotWidthOpt);
var screenshotHeight = result.GetValue(screenshotHeightOpt);
// --grid has three states: absent → off (0), present with no value
// (bare --grid) → auto (-1), present with a value → parse it.
var gridResult = result.GetResult(gridOpt);
var gridCols = gridResult is null ? 0
: gridResult.Tokens.Count == 0 ? -1
: ParseGridSpec(gridResult.Tokens[0].Value);
var renderMode = (result.GetValue(renderOpt) ?? "auto").ToLowerInvariant();
if (renderMode is not ("auto" or "native" or "html"))
throw new OfficeCli.Core.CliException($"Invalid --render value: {renderMode}. Valid: auto, native, html") { Code = "invalid_render", ValidValues = ["auto", "native", "html"] };
var withPages = result.GetValue(withPagesOpt);
// pdf mode runs entirely through an exporter plugin (no handler
// open, no resident hop — the plugin gets a snapshot of the
// source and writes the PDF). Handled before TryResident
// because exporter invocation needs the file lock released, and
// ExporterInvoker closes the resident itself when present.
if (mode.ToLowerInvariant() is "pdf")
{
var pdfPath = outArg ?? Path.ChangeExtension(file.FullName, "pdf");
var exp = OfficeCli.Core.Plugins.ExporterInvoker.Run(file.FullName, ".pdf", pdfPath);
if (json)
{
Console.WriteLine(OutputFormatter.WrapEnvelopeText(exp.OutputPath));
}
else
{
Console.WriteLine(Path.GetFullPath(exp.OutputPath));View on GitHub (pinned to 1ced45e900)
Solutions
- Use --render auto (let it choose), native, or html.
- Omit --render entirely — auto is the default.
Example fix
// before officecli view deck.pptx screenshot --render canvas // after officecli view deck.pptx screenshot --render html
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> RenderModes = new(StringComparer.OrdinalIgnoreCase) { "auto", "native", "html" };
if (!RenderModes.Contains(renderMode))
throw new ArgumentException($"--render must be one of: {string.Join(", ", RenderModes)}."); Type guard
static bool IsValidRenderMode(string? r) =>
r is null || r.ToLowerInvariant() is "auto" or "native" or "html"; Prevention
- --render is one of {auto, native, html}; auto is the safe default.
- Do not conflate render backend names with view modes (pdf/svg are modes).
When it happens
Trigger: 'officecli view deck.pptx screenshot --render canvas' or any --render value outside {auto, native, html}.
Common situations: Typo; guessing a render backend name; passing 'pdf' or 'svg' (those are separate view modes, not render backends).
Related errors
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/bcaa885eda29ce7f.
Report an issue: GitHub.