{"record":{"id":"fb0b8f3ed456366c","repo":"iOfficeAI/OfficeCLI","slug":"invalid-format","errorCode":"invalid_format","errorMessage":"Unsupported --format: {format}. Valid: batch","messagePattern":"Unsupported --format: (.+?)\\. Valid: batch","errorType":"error_code","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.Dump.cs","lineNumber":47,"sourceCode":"        };\n        var outOpt = new Option<string?>(\"--out\", \"-o\") { Description = \"Write output to a file instead of stdout\" };\n\n        var dumpCommand = new Command(\"dump\", \"Serialize a document subtree into a replayable batch script (round-trip mechanism)\");\n        dumpCommand.Add(dumpFileArg);\n        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.\")","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.Dump.cs#L29-L65","documentation":"Thrown by the `dump` command when --format is anything other than `batch` (case-insensitive). dump currently serializes only to the replayable batch format; the guard at line 46-48 rejects other values with code `invalid_format` and a ValidValues list of `['batch']`.","triggerScenarios":"`officecli dump file.docx / --format json`, `--format xml`, `--format csv`, etc. format.ToLowerInvariant() != \"batch\" triggers the throw.","commonSituations":"User assumes dump supports json/xml like query/get do; a script passes a generic --format from a shared options object; an agent guesses a format value.","solutions":["Drop --format (defaults to batch) or pass `--format batch` explicitly.","For JSON output of the document tree use `get --json` or `query --json` instead of dump.","Watch release notes — additional formats may be added later."],"exampleFix":"# before\nofficecli dump file.docx / --format json\n\n# after\nofficecli dump file.docx / --format batch\n# or simply\nofficecli dump file.docx /","handlingStrategy":"validation","validationCode":"// Only allow the supported dump format.\nvar fmt = (format ?? \"batch\").ToLowerInvariant();\nif (fmt != \"batch\") throw new ArgumentException(\"dump --format only accepts 'batch'\");","typeGuard":"// Guard: format is supported by dump.\nstatic bool DumpFormatSupported(string? f) =>\n    (f ?? \"batch\").ToLowerInvariant() == \"batch\";","tryCatchPattern":null,"preventionTips":["Do not pass a shared --format flag into dump from a generic options object.","Use get/query --json when you need JSON tree output, not dump --format json."],"tags":["argument-validation","dump","format","invalid-format"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}