iOfficeAI/OfficeCLI · error · CliException

invalid_value

invalid_value

Error message

shift is supported only for Excel cell paths (e.g. /Sheet1/B5).

What it means

Thrown by RemoveWithShiftSupport when the props dictionary carries a non-empty "shift" key but the active document handler is not the ExcelHandler. shift=left|up only has meaning for Excel cell deletion (it routes to RemoveCellWithShift); Word and PowerPoint ignore it under plain Remove, so passing it on those types is treated as a caller mistake rather than silently dropped. CliException with Code="invalid_value".

Source

Thrown at src/officecli/CommandBuilder.cs:737

        {
            Console.Error.WriteLine($"Error: {OfficeCli.Core.MsysPathHint.AugmentMessage(rendered.Message)}");
        }
    }

    /// <summary>
    /// Remove a path, honouring a prop-carried <c>shift</c> (Excel cell delete
    /// with shift=left|up). The CLI exposes shift via a dedicated --shift option
    /// that routes to <c>RemoveCellWithShift</c>; the MCP single-command and
    /// batch surfaces carry it inside props, so without this they silently
    /// dropped it (plain <c>Remove</c> ignores props["shift"]). Shared so all
    /// three surfaces behave identically. Returns the handler's warning (or null).
    /// </summary>
    internal static string? RemoveWithShiftSupport(OfficeCli.Core.IDocumentHandler handler, string path, Dictionary<string, string>? props)
    {
        if (props != null && props.TryGetValue("shift", out var shift) && !string.IsNullOrEmpty(shift))
        {
            if (handler is not OfficeCli.Handlers.ExcelHandler xl)
                throw new OfficeCli.Core.CliException("shift is supported only for Excel cell paths (e.g. /Sheet1/B5).")
                    { Code = "invalid_value" };
            return xl.RemoveCellWithShift(path, shift);
        }
        return handler.Remove(path, props);
    }

    /// <summary>Categorised result of <see cref="ApplySetWithCorrection"/>.</summary>
    internal sealed record SetApplyOutcome(
        List<KeyValuePair<string, string>> Applied,
        List<string> Unsupported,
        List<(string Original, string Corrected, string Value)> AutoCorrected);

    /// <summary>
    /// Apply a set's props, auto-correct any unsupported key that is a unique
    /// Levenshtein-distance-1 typo of a real prop (e.g. colot→color), and
    /// categorise the result into applied / still-unsupported / auto-corrected.
    ///
    /// This is the ONE shared core behind every set surface — the non-resident

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Drop the shift prop for non-Excel files; only Word/PowerPoint paths reach this branch.
  2. Only emit shift when the document is .xlsx and the path targets a cell (e.g. /Sheet1/B5).
  3. Type-check the handler/document before constructing the props dict.
  4. In a cross-type batch driver, branch on file extension and omit shift for non-xlsx.

Example fix

// before
{"command":"remove","path":"/slide[1]","props":{"shift":"left"}}
// after
{"command":"remove","path":"/slide[1]"}
Defensive patterns

Strategy: validation

Validate before calling

// Only attach shift for Excel cell paths.
var props = new Dictionary<string,string>();
if (handler is ExcelHandler && IsCellPath(path))
    props["shift"] = shiftDir;   // "left" | "up"
// otherwise omit shift entirely

Type guard

static bool IsExcelCellPath(IDocumentHandler h, string path)
    => h is ExcelHandler && path.StartsWith("/") && Regex.IsMatch(path, @"^/[^/]+/[A-Z]+[0-9]+");

Prevention

When it happens

Trigger: A batch or MCP remove step with a shift prop on a non-Excel file: {"command":"remove","path":"/slide[1]","props":{"shift":"left"}}; replaying an Excel dump/replay against a .docx; a generic remove helper that always attaches shift.

Common situations: A reusable batch template applied across file types; an MCP single-command that forwards shift unconditionally; copy of an Excel-oriented step into a Word/PPT workflow without stripping shift.

Related errors


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