{"record":{"id":"d542e65d58b85631","repo":"iOfficeAI/OfficeCLI","slug":"file-not-found-d542e6","errorCode":"file_not_found","errorMessage":"File not found: {file.FullName}. Use 'officecli create {file.FullName}' to create a blank document, or check the file extension.","messagePattern":"File not found: (.+?)\\. Use 'officecli create (.+?)' to create a blank document, or check the file extension\\.","errorType":"error_code","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.Dump.cs","lineNumber":62,"sourceCode":"            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\").\n            // Mirrors the TryResident calls in `get`/`query`/`set`.\n            if (TryResident(file.FullName, req =>\n            {\n                req.Command = \"dump\";\n                req.Json = json;\n                req.Args[\"path\"] = path;\n                req.Args[\"format\"] = format;\n                if (!string.IsNullOrEmpty(outPath)) req.Args[\"out\"] = outPath!;\n            }, json) is {} rc) return rc;\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.Dump.cs#L44-L80","documentation":"Thrown by the `dump` command when the target document file does not exist on disk. Tagged CONSISTENCY(file-not-found): without this early guard, dump fell through to the SDK opener whose raw '.NET Could not find file' message disagreed with every other command. The guard (line 61-66) raises a CliException with code `file_not_found` and an actionable suggestion to run `create`.","triggerScenarios":"`officecli dump /missing.docx /`, or any dump against a path that does not resolve to an existing file (typo, wrong cwd, not-yet-created document).","commonSituations":"Typo in the document path; script runs from a different cwd so a relative path misses; the document was supposed to be generated by a prior step that failed; the file was deleted/moved between commands.","solutions":["Verify the path: `ls -l <file>` from OfficeCLI's cwd; use an absolute path.","If the document does not exist yet, create it first: `officecli create <path>` (the error message suggests this).","Fix the producing step so the file exists before dump runs."],"exampleFix":"# before\nofficecli dump /misspelled.docx /\n\n# after\nofficecli create ./report.docx\nofficecli dump ./report.docx /","handlingStrategy":"validation","validationCode":"// Verify the target exists before dump.\nif (!File.Exists(file.FullName))\n    throw new FileNotFoundException($\"File not found: {file.FullName}\");","typeGuard":"// Guard: target document is present.\nstatic bool DumpTargetReady(string path) => File.Exists(path);","tryCatchPattern":null,"preventionTips":["Use absolute paths and a single source-of-truth for the document path across the pipeline.","Create the document with `officecli create` first if it does not yet exist."],"tags":["file-not-found","dump","cli","consistency"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}