{"record":{"id":"17ad65ed4d316745","repo":"iOfficeAI/OfficeCLI","slug":"unsupported-type-17ad65","errorCode":"unsupported_type","errorMessage":"refresh currently only supports .docx files (got {ext}).","messagePattern":"refresh currently only supports \\.docx files \\(got (.+?)\\)\\.","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.Refresh.cs","lineNumber":31,"sourceCode":"        var fileArg = new Argument<FileInfo>(\"file\") { Description = \"Office document path\" };\n\n        var cmd = new Command(\"refresh\", \"Recalculate derived field values (TOC page numbers, PAGE/NUMPAGES, cross-references). Word + Windows required for .docx.\");\n        cmd.Add(fileArg);\n        cmd.Add(jsonOption);\n\n        cmd.SetAction(result => { var json = result.GetValue(jsonOption); return SafeRun(() =>\n        {\n            var file = result.GetValue(fileArg)!;\n\n            if (TryResident(file.FullName, req =>\n            {\n                req.Command = \"refresh\";\n                req.Json = json;\n            }, json) is { } rc) return rc;\n\n            var ext = Path.GetExtension(file.FullName).ToLowerInvariant();\n            if (ext != \".docx\" && ext != \".docm\")\n                throw new CliException($\"refresh currently only supports .docx files (got {ext}).\")\n                { Code = \"unsupported_type\" };\n\n            bool ok = false;\n            string backend = \"\";\n            if (OperatingSystem.IsWindows())\n            {\n                ok = WordPdfBackend.RefreshFields(file.FullName);\n                if (ok) backend = \"word\";\n            }\n            if (!ok)\n            {\n                ok = WordHtmlRefresh.RefreshViaHtml(file.FullName);\n                if (ok) backend = \"html\";\n            }\n            if (!ok)\n                throw new CliException(\"refresh failed (Word backend unavailable and HTML fallback failed — no headless browser found).\")\n                { Code = \"refresh_failed\" };\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.Refresh.cs#L13-L49","documentation":"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).","triggerScenarios":"'officecli refresh deck.pptx' or 'officecli refresh sheet.xlsx' — any non-.docx/.docm target.","commonSituations":"Assuming refresh is format-agnostic; pointing refresh at a presentation or spreadsheet that has no derived fields to refresh.","solutions":["Use a .docx or .docm file.","For other formats, refresh is not applicable — skip the call."],"exampleFix":"// before\nofficecli refresh deck.pptx\n// after\nofficecli refresh document.docx","handlingStrategy":"validation","validationCode":"var ext = Path.GetExtension(file).ToLowerInvariant();\nif (ext != \".docx\" && ext != \".docm\")\n    throw new ArgumentException($\"refresh is .docx/.docm only, got '{ext}'.\");","typeGuard":"static bool IsRefreshable(string f)\n{\n    var e = Path.GetExtension(f).ToLowerInvariant();\n    return e == \".docx\" || e == \".docm\";\n}","tryCatchPattern":null,"preventionTips":["Refresh targets derived fields that only Word documents have.","Gate refresh on .docx/.docm in automation.","Do not call refresh on pptx/xlsx."],"tags":["refresh","unsupported-type","docx"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}