iOfficeAI/OfficeCLI · error · CliException

path_not_found

path_not_found

Error message

dump path not found: {path} (no such sheet)

What it means

Thrown by ExcelBatchEmitter.EmitExcel when the dump path token (after trimming slashes) does not match any sheet in the workbook. The emitter calls xl.ResolveDumpSheetName(token) which tries to resolve the token as a sheet name (case-insensitive) or as a '/sheet[N]' index. If no match is found, the path is reported as not found. This is the Excel equivalent of a 404 for dump paths.

Source

Thrown at src/officecli/Handlers/Excel/ExcelBatchEmitter.cs:192

    /// NOT included (they live at sibling paths — mirrors the docx/pptx
    /// subtree contract).
    /// </summary>
    public static (List<BatchItem> Items, List<UnsupportedWarning> Warnings) EmitExcel(
        ExcelHandler xl, string path)
    {
        const string SupportedHint = "Supported: /, /SheetName, /sheet[N]";
        if (string.IsNullOrEmpty(path))
            throw new CliException($"dump path cannot be empty. Use '/' for the full document or a sheet path like /Sheet1. {SupportedHint}")
                { Code = "invalid_path" };
        if (path == "/") return EmitExcel(xl);

        var token = path.Trim('/');
        if (token.Length == 0 || token.Contains('/'))
            throw new CliException($"dump path not supported: {path}. {SupportedHint}")
                { Code = "unsupported_path" };

        var sheetName = xl.ResolveDumpSheetName(token)
            ?? throw new CliException($"dump path not found: {path} (no such sheet)")
                { Code = "path_not_found" };

        var items = new List<BatchItem>();
        var warnings = new List<UnsupportedWarning>();
        EmitSheet(xl, sheetName, renameFirstSheet: false, items, warnings, claimExistingSheet: true);
        EmitPivotTables(xl, "/" + sheetName, xl.GetDumpPivotCount(sheetName), items, warnings);
        EmitSlicers(xl, "/" + sheetName, xl.GetDumpSlicerCount(sheetName), items, warnings);
        return (items, warnings);
    }

    private static void EmitWorkbookSettings(ExcelHandler xl, List<BatchItem> items,
        List<UnsupportedWarning> warnings)
    {
        DocumentNode wb;
        try { wb = xl.GetDumpWorkbookNode(); }
        catch { return; }

        var props = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

View on GitHub (pinned to 1ced45e900)

Solutions

  1. List available sheets first: use the query or get command on '/' to enumerate sheets.
  2. Check the sheet name spelling and casing.
  3. If using '/sheet[N]' index form, verify N is within the valid range (0-based, up to sheet count - 1).
  4. Ensure any preceding 'add sheet' commands in a batch completed successfully before dumping.
Defensive patterns

Strategy: validation

Validate before calling

// Verify the sheet exists before dumping
var sheetNames = xl.GetSheetNames(); // or equivalent enumeration
if (!sheetNames.Any(s => s.Equals(sheetToken, StringComparison.OrdinalIgnoreCase)))
    throw new InvalidOperationException($"No sheet matching '{sheetToken}'");
var (items, warnings) = ExcelBatchEmitter.EmitExcel(xl, "/" + sheetToken);

Try / catch

try
{
    var (items, warnings) = ExcelBatchEmitter.EmitExcel(xl, path);
}
catch (CliException ex) when (ex.Code == "path_not_found")
{
    // Sheet not found — enumerate available sheets and report
    logger.LogError("Sheet not found for path '{Path}'. Available sheets: {Sheets}",
        path, string.Join(", ", xl.GetSheetNames()));
    throw;
}

Prevention

When it happens

Trigger: Passing '/NonexistentSheet' when the workbook has no sheet by that name; passing '/sheet[5]' when the workbook has only 3 sheets; a typo in the sheet name; the sheet was deleted between the time the path was constructed and the dump was called.

Common situations: A dump command targeting a sheet name that was mistyped or that does not exist in the current version of the workbook; a batch replay where the sheet was supposed to be created by an earlier command that failed silently; a case mismatch on a case-sensitive platform.

Related errors


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