{"record":{"id":"eae03968aadef0a7","repo":"iOfficeAI/OfficeCLI","slug":"unsupported-format","errorCode":"unsupported_format","errorMessage":"dump currently supports .docx, .pptx and .xlsx (got {ext})","messagePattern":"dump currently supports \\.docx, \\.pptx and \\.xlsx \\(got (.+?)\\)","errorType":"error_code","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.Dump.cs","lineNumber":52,"sourceCode":"        dumpCommand.Add(dumpPathArg);\n        dumpCommand.Add(formatOpt);\n        dumpCommand.Add(outOpt);\n        dumpCommand.Add(jsonOption);\n\n        dumpCommand.SetAction(result => { var json = result.GetValue(jsonOption); return SafeRun(() =>\n        {\n            var file = result.GetValue(dumpFileArg)!;\n            var path = OfficeCli.Core.MsysPathHint.Restore(result.GetValue(dumpPathArg)) ?? \"/\";\n            var format = (result.GetValue(formatOpt) ?? \"batch\").ToLowerInvariant();\n            var outPath = result.GetValue(outOpt);\n\n            if (format != \"batch\")\n                throw new CliException($\"Unsupported --format: {format}. Valid: batch\")\n                    { Code = \"invalid_format\", ValidValues = [\"batch\"] };\n\n            var ext = Path.GetExtension(file.FullName).ToLowerInvariant();\n            if (ext != \".docx\" && ext != \".pptx\" && ext != \".xlsx\")\n                throw new CliException($\"dump currently supports .docx, .pptx and .xlsx (got {ext})\")\n                    { Code = \"unsupported_format\" };\n\n            // CONSISTENCY(file-not-found): mirror the get/set/query format —\n            // \"File not found: <path>. Use 'officecli create <path>' to create a\n            // blank document, or check the file extension.\". Without this\n            // early guard the dump path falls through to the SDK opener whose\n            // raw '.NET Could not find file' message disagrees with every\n            // other command and skips the actionable suggestion.\n            if (!File.Exists(file.FullName))\n                throw new CliException(\n                    $\"File not found: {file.FullName}. \" +\n                    $\"Use 'officecli create {file.FullName}' to create a blank document, \" +\n                    $\"or check the file extension.\")\n                    { Code = \"file_not_found\" };\n\n            // BUG-DUMP-R6-01: route through the resident if one holds the file.\n            // Without this, dump opens its own handler and collides with\n            // the resident's lock (\"file being used by another process\").","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.Dump.cs#L34-L70","documentation":"Thrown by the `dump` command when the target file's extension is not .docx, .pptx, or .xlsx. dump only serializes the three supported Office formats; the extension check at line 50-53 rejects others with code `unsupported_format` before attempting to open the file.","triggerScenarios":"`officecli dump file.pdf /`, `officecli dump file.odt /`, `officecli dump file.doc /` (legacy .doc, not .docx).","commonSituations":"User points dump at a PDF or legacy Office format; a script passes any file without checking the extension; confusion between .doc and .docx; an ODF file mistaken for OOXML.","solutions":["Convert or re-save the file as .docx/.pptx/.xlsx first.","Point dump at a genuine OOXML file.","For legacy .doc/.ppt, open in the Office app and Save As the modern format."],"exampleFix":"# before\nofficecli dump file.doc /\n\n# after\nofficecli dump file.docx /","handlingStrategy":"validation","validationCode":"// Check extension before dump.\nvar ext = Path.GetExtension(file).ToLowerInvariant();\nif (ext is not (\".docx\" or \".pptx\" or \".xlsx\"))\n    throw new NotSupportedException($\"dump unsupported extension {ext}\");","typeGuard":"// Guard: extension is dumpable.\nstatic bool IsDumpable(string path) =>\n    Path.GetExtension(path).ToLowerInvariant() is \".docx\" or \".pptx\" or \".xlsx\";","tryCatchPattern":null,"preventionTips":["Whitelist the three OOXML extensions at the input boundary.","Distinguish legacy .doc/.ppt/.xls from the modern formats before calling dump."],"tags":["file-format","dump","unsupported","extension"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}