iOfficeAI/OfficeCLI · error · CliException
unsupported_type
unsupported_type
Error message
refresh currently only supports .docx files (got {ext}). What it means
The refresh command (recalculate TOC page numbers, PAGE/NUMPAGES, cross-references) only supports .docx/.docm in V1. This fires when the target file's extension is anything else (e.g. .pptx, .xlsx, .doc).
Source
Thrown at src/officecli/CommandBuilder.Refresh.cs:31
var fileArg = new Argument<FileInfo>("file") { Description = "Office document path" };
var cmd = new Command("refresh", "Recalculate derived field values (TOC page numbers, PAGE/NUMPAGES, cross-references). Word + Windows required for .docx.");
cmd.Add(fileArg);
cmd.Add(jsonOption);
cmd.SetAction(result => { var json = result.GetValue(jsonOption); return SafeRun(() =>
{
var file = result.GetValue(fileArg)!;
if (TryResident(file.FullName, req =>
{
req.Command = "refresh";
req.Json = json;
}, json) is { } rc) return rc;
var ext = Path.GetExtension(file.FullName).ToLowerInvariant();
if (ext != ".docx" && ext != ".docm")
throw new CliException($"refresh currently only supports .docx files (got {ext}).")
{ Code = "unsupported_type" };
bool ok = false;
string backend = "";
if (OperatingSystem.IsWindows())
{
ok = WordPdfBackend.RefreshFields(file.FullName);
if (ok) backend = "word";
}
if (!ok)
{
ok = WordHtmlRefresh.RefreshViaHtml(file.FullName);
if (ok) backend = "html";
}
if (!ok)
throw new CliException("refresh failed (Word backend unavailable and HTML fallback failed — no headless browser found).")
{ Code = "refresh_failed" };
View on GitHub (pinned to 1ced45e900)
Solutions
- Use a .docx or .docm file.
- For other formats, refresh is not applicable — skip the call.
Example fix
// before officecli refresh deck.pptx // after officecli refresh document.docx
Defensive patterns
Strategy: validation
Validate before calling
var ext = Path.GetExtension(file).ToLowerInvariant();
if (ext != ".docx" && ext != ".docm")
throw new ArgumentException($"refresh is .docx/.docm only, got '{ext}'."); Type guard
static bool IsRefreshable(string f)
{
var e = Path.GetExtension(f).ToLowerInvariant();
return e == ".docx" || e == ".docm";
} Prevention
- Refresh targets derived fields that only Word documents have.
- Gate refresh on .docx/.docm in automation.
- Do not call refresh on pptx/xlsx.
When it happens
Trigger: 'officecli refresh deck.pptx' or 'officecli refresh sheet.xlsx' — any non-.docx/.docm target.
Common situations: Assuming refresh is format-agnostic; pointing refresh at a presentation or spreadsheet that has no derived fields to refresh.
Related errors
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/17ad65ed4d316745.
Report an issue: GitHub.