{"record":{"id":"e709e8558489da79","repo":"iOfficeAI/OfficeCLI","slug":"cell-runcellref-not-found","errorCode":null,"errorMessage":"Cell {runCellRef} not found","messagePattern":"Cell (.+?) not found","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Query.cs","lineNumber":927,"sourceCode":"\n            // Generic XML fallback: navigate worksheet XML tree\n            var xmlSegments = GenericXmlQuery.ParsePathSegments(cellRef);\n            var target = GenericXmlQuery.NavigateByPath(GetSheet(worksheet), xmlSegments);\n            if (target == null)\n                return new DocumentNode { Path = path, Type = \"error\", Text = $\"Element not found: {cellRef}\" };\n            return GenericXmlQuery.ElementToNode(target, path, depth);\n        }\n\n        // Handle /SheetName/A1/run[N] (rich text run direct access)\n        var runGetMatch = Regex.Match(cellRef, @\"^([A-Z]+\\d+)/run\\[(\\d+)\\]$\", RegexOptions.IgnoreCase);\n        if (runGetMatch.Success)\n        {\n            var runCellRef = runGetMatch.Groups[1].Value.ToUpperInvariant();\n            var runIdx = int.Parse(runGetMatch.Groups[2].Value);\n            ParseCellReference(runCellRef);\n            var runCell = FindCell(data, runCellRef);\n            if (runCell == null)\n                throw new ArgumentException($\"Cell {runCellRef} not found\");\n            if (runCell.DataType?.Value != CellValues.SharedString ||\n                !int.TryParse(runCell.CellValue?.Text, out var sstIdx))\n                throw new ArgumentException($\"Cell {runCellRef} is not a rich text cell\");\n            var sstPart = _doc.WorkbookPart?.GetPartsOfType<SharedStringTablePart>().FirstOrDefault();\n            var ssi = sstPart?.SharedStringTable?.Elements<SharedStringItem>().ElementAtOrDefault(sstIdx);\n            if (ssi == null) throw new ArgumentException($\"SharedString entry {sstIdx} not found\");\n            var runs = ssi.Elements<Run>().ToList();\n            if (runIdx < 1 || runIdx > runs.Count)\n                throw new ArgumentException($\"Run index {runIdx} out of range (1-{runs.Count})\");\n            return RunToNode(runs[PathIndex.ToArrayIndex(runIdx)], $\"/{sheetNameFromPath}/{runCellRef}/run[{runIdx}]\");\n        }\n\n        if (cellRef.Contains(':'))\n        {\n            // Range — validate both endpoints\n            var rangeParts = cellRef.Split(':');\n            ParseCellReference(rangeParts[0]);\n            if (rangeParts.Length > 1) ParseCellReference(rangeParts[1]);","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Query.cs#L909-L945","documentation":"Thrown in the rich-text run direct-access path (A1/run[N]). The cell reference parses successfully (ParseCellReference passes) but FindCell returns null — the coordinate is valid but the cell does not exist in the sheet (it is empty/never written). Without a cell there is no shared-string index and no runs to index.","triggerScenarios":"get /Sheet1/Z99/run[1] where Z99 is empty; any A1/run[N] against a cell that has no value. ParseCellReference already validated the A1 shape, so only truly absent cells reach here.","commonSituations":"Reading runs from a cell the user assumes has rich text but is blank; off-by-one in a generated coordinate; querying a sheet region beyond the used range.","solutions":["Verify the cell exists first: get /Sheet1/Z99 and confirm it returns a value before appending /run[N].","Correct the coordinate to a cell known to contain rich/shared-string text.","If iterating, restrict your loop to the sheet's used range so you only hit populated cells."],"exampleFix":"// before\nget /Sheet1/Z99/run[1]\n// after\nget /Sheet1/A1/run[1]   // A1 actually contains rich text","handlingStrategy":"validation","validationCode":"# verify the cell exists before requesting a run\nnode = doc.get('/Sheet1/Z99')\nif node.get('type') == 'error' or not node.get('text'):\n    raise SystemExit('cell is empty — no runs to index')\ndoc.get('/Sheet1/Z99/run[1]')","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Confirm a cell is populated (get it first) before appending /run[N].","Constrain run-iteration loops to the sheet's used range.","Treat an empty cell as 'no runs' rather than indexing it."],"tags":["excel","rich-text","run","not-found","get"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}