{"record":{"id":"728785460123a20e","repo":"iOfficeAI/OfficeCLI","slug":"invalid-range-range","errorCode":null,"errorMessage":"Invalid range: {range}","messagePattern":"Invalid range: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.Cell.cs","lineNumber":347,"sourceCode":"        var dimParts = range.Split(':');\n        if (dimParts.Length != 2) return false;\n        var m1 = System.Text.RegularExpressions.Regex.Match(dimParts[0], @\"^([A-Z]+)(\\d+)$\");\n        var m2 = System.Text.RegularExpressions.Regex.Match(dimParts[1], @\"^([A-Z]+)(\\d+)$\");\n        if (!m1.Success || !m2.Success) return false;\n        var c1 = ColumnNameToIndex(m1.Groups[1].Value);\n        var c2 = ColumnNameToIndex(m2.Groups[1].Value);\n        var r1 = int.Parse(m1.Groups[2].Value);\n        var r2 = int.Parse(m2.Groups[2].Value);\n        rows = Math.Abs(r2 - r1) + 1;\n        cols = Math.Abs(c2 - c1) + 1;\n        return true;\n    }\n\n    private DocumentNode GetCellRange(string sheetName, SheetData sheetData, string range, int depth, WorksheetPart? part = null)\n    {\n        var parts = range.Split(':');\n        if (parts.Length != 2)\n            throw new ArgumentException($\"Invalid range: {range}\");\n\n        var (startCol, startRow) = ParseCellReference(parts[0]);\n        var (endCol, endRow) = ParseCellReference(parts[1]);\n        var startColIdx = ColumnNameToIndex(startCol);\n        var endColIdx = ColumnNameToIndex(endCol);\n\n        var node = new DocumentNode\n        {\n            Path = $\"/{sheetName}/{range}\",\n            Type = \"range\",\n            Preview = range\n        };\n\n        // Build lookup of existing cells so we can fill empty stubs for missing positions\n        var existingCells = new Dictionary<string, Cell>(StringComparer.OrdinalIgnoreCase);\n        foreach (var row in sheetData.Elements<Row>())\n        {\n            var rowIdx = (int)(row.RowIndex?.Value ?? 0);","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.Cell.cs#L329-L365","documentation":"GetCellRange requires the range string to split into exactly two colon-separated cell references and throws otherwise. This is the read/range path invoked from Query.cs:946 for DOM-style range reads. A single cell (no colon) or a malformed multi-colon range (A1:B2:C3) both fail here. ParseCellReference/ColumnNameToIndex are then applied to each half, so the two halves must be valid A1 refs.","triggerScenarios":"Get path '/Sheet1/A1' routed as a range (no colon); range 'A1:B2:C3' (extra colon); range built by string concatenation that dropped one anchor.","commonSituations":"Passing a single-cell ref where a range is required; query router mishandling a cell vs range; truncation or duplication of the colon during ref assembly.","solutions":["Pass a proper two-anchor range 'A1:B2'.","For single cells, use the cell path rather than the range path.","Validate that the string contains exactly one ':' before calling.","Trim whitespace and strip stray characters from the range."],"exampleFix":"// before\nhandler.Get(path: \"/Sheet1/A1\", ...);   // single cell -> range split fails\n\n// after\nhandler.Get(path: \"/Sheet1/A1:A1\", ...); // valid degenerate range","handlingStrategy":"validation","validationCode":"static bool IsRangeRef(string r) =>\n    !string.IsNullOrWhiteSpace(r) && r.Split(':').Length == 2;\n\nif (!IsRangeRef(range))\n    throw new ArgumentException($\"Not a two-anchor range: {range}\");","typeGuard":"static bool IsRangeRef(string r) =>\n    r?.Split(':') is { Length: 2 };","tryCatchPattern":null,"preventionTips":["Always pass a two-anchor range 'A1:B2' to range-read paths.","Use the cell path for single cells, not the range path.","Validate exactly one colon before calling.","Guard against stray colons introduced by string concatenation."],"tags":["excel","ooxml","range","query","validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}