iOfficeAI/OfficeCLI · error · FileNotFoundException

Input file not found: {inputFile.FullName}

Error message

Input file not found: {inputFile.FullName}

What it means

Thrown by the `batch` command when --input names a file (not the '-' stdin alias) that does not exist on disk. The explicit inputFile.Exists check at line 244 raises FileNotFoundException with the full path.

Source

Thrown at src/officecli/CommandBuilder.Batch.cs:246

            }
            else if (inputFile != null)
            {
                // Accept the conventional Unix '-' alias for stdin so
                // pipelines like `cat ops.json | officecli batch foo.pptx --input -`
                // don't have to drop --input entirely. Matches the implicit
                // "no --input ⇒ read stdin" branch below; using --input -
                // makes the intent explicit instead of relying on the
                // absent-flag default. (TargetMode/Exists checks are
                // skipped on purpose — '-' is not a path.)
                if (inputFile.Name == "-")
                {
                    jsonText = StripBom(StdIn.ReadToEnd());
                }
                else
                {
                    if (!inputFile.Exists)
                    {
                        throw new FileNotFoundException($"Input file not found: {inputFile.FullName}");
                    }
                    jsonText = File.ReadAllText(inputFile.FullName);
                }
            }
            else
            {
                // Read from stdin. File.ReadAllText auto-detects and strips
                // UTF-8 BOM; Console.In does not. Without an explicit strip,
                // `cat utf8bom.json | officecli batch foo.pptx` failed
                // System.Text.Json.Parse with "'' is an invalid start of
                // a value" while `batch --input utf8bom.json` succeeded —
                // splitting the contract on the input source.
                jsonText = StripBom(StdIn.ReadToEnd());
            }

            // Pre-validate: check for unknown JSON fields before deserializing
            var jsonDoc = System.Text.Json.JsonDocument.Parse(jsonText);
            // CONSISTENCY(dump-batch-pipeline): `dump --json` wraps the

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Verify the path exists and is readable: `ls -l <input-file>` from the same cwd OfficeCLI runs in.
  2. Use an absolute path to avoid cwd-relative misses.
  3. If you meant stdin, use `--input -` or omit --input entirely (batch reads stdin by default).
  4. Ensure the file-generating step succeeded before invoking batch.

Example fix

# before
officecli batch file.docx --input ops.json   # wrong cwd

# after
officecli batch file.docx --input /abs/path/ops.json
Defensive patterns

Strategy: validation

Validate before calling

// Resolve and check the input file before invoking batch.
var fi = new FileInfo(inputPath);
if (inputPath != "-" && !fi.Exists)
    throw new FileNotFoundException($"batch input not found: {fi.FullName}");

Type guard

// Guard: batch input source is usable.
static bool BatchInputReady(string? src) =>
    src is null || src == "-" || File.Exists(src);

Prevention

When it happens

Trigger: `officecli batch file.docx --input /tmp/ops.json` where /tmp/ops.json is absent, mis-spelled, on an unmounted volume, or relative to a different working directory than expected.

Common situations: Typo in the path; script ran from a different cwd so a relative path misses; the ops file was generated by a prior step that failed silently; permissions hide the file; the path was templated with an empty variable.

Related errors


AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13). Data as JSON: /api/errors/45d361948a4873b9. Report an issue: GitHub.