{"record":{"id":"28fdd2b71f1d5cfb","repo":"iOfficeAI/OfficeCLI","slug":"slicer-slidx-not-found-on-sheet-sheetnamefrom","errorCode":null,"errorMessage":"slicer[{slIdx}] not found on sheet '{sheetNameFromPath}'","messagePattern":"slicer\\[(.+?)\\] not found on sheet '(.+?)'","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Query.cs","lineNumber":771,"sourceCode":"            var ptIdx = int.Parse(pivotMatch.Groups[1].Value);\n            var pivotParts = worksheet.PivotTableParts.ToList();\n            if (ptIdx < 1 || ptIdx > pivotParts.Count)\n                throw new ArgumentException($\"PivotTable index {ptIdx} out of range (1-{pivotParts.Count})\");\n\n            var pivotPart = pivotParts[ptIdx - 1];\n            var ptNode = new DocumentNode { Path = path, Type = \"pivottable\" };\n            if (pivotPart.PivotTableDefinition != null)\n                PivotTableHelper.ReadPivotTableProperties(pivotPart.PivotTableDefinition, ptNode, pivotPart);\n            return ptNode;\n        }\n\n        // Slicer path: /Sheet1/slicer[N]\n        var slicerMatch = Regex.Match(cellRef, @\"^slicer\\[(\\d+)\\]$\", RegexOptions.IgnoreCase);\n        if (slicerMatch.Success)\n        {\n            var slIdx = int.Parse(slicerMatch.Groups[1].Value);\n            if (!TryFindSlicerByIndex(worksheet, slIdx, out var slicerElem, out var slicerCache) || slicerElem == null)\n                throw new ArgumentException($\"slicer[{slIdx}] not found on sheet '{sheetNameFromPath}'\");\n            var slNode = new DocumentNode { Path = path, Type = \"slicer\" };\n            ReadSlicerProperties(slicerElem, slicerCache, slNode);\n            return slNode;\n        }\n\n        // OLE object path: /Sheet1/ole[N]\n        // CONSISTENCY(ole-alias): \"oleobject\" mirrors Add's case switch\n        var oleMatch = Regex.Match(cellRef, @\"^(?:ole|oleobject|object|embed)\\[(\\d+)\\]$\", RegexOptions.IgnoreCase);\n        if (oleMatch.Success)\n        {\n            var oleIdx = int.Parse(oleMatch.Groups[1].Value);\n            var oleList = CollectOleNodesForSheet(sheetNameFromPath, worksheet);\n            if (oleIdx < 1 || oleIdx > oleList.Count)\n                throw new ArgumentException($\"OLE object {oleIdx} not found at /{sheetNameFromPath} (available: {oleList.Count}).\");\n            return oleList[oleIdx - 1];\n        }\n\n        // Comment path: /Sheet1/comment[N]","sourceCodeStart":753,"sourceCodeEnd":789,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Query.cs#L753-L789","documentation":"Thrown for /Sheet/slicer[N] when TryFindSlicerByIndex finds no slicer at that 1-based index on the sheet. Slicers are cross-referenced through their cache parts and can live in the worksheet's SlicerList or a timeline cache; a missing or invalid index (including slicer[0]) yields this not-found error.","triggerScenarios":"handler.Get(\"/Sheet1/slicer[3]\") on a sheet with fewer than 3 slicers (or none). slicer[0].","commonSituations":"Hard-coded slicer index after slicers were deleted. Sheet has timelines but no slicers (or vice versa). Zero-based indexing.","solutions":["Use a 1-based index within the slicer count.","Confirm slicers exist on the sheet before indexing.","try/catch(ArgumentException) and degrade to 'no slicer'."],"exampleFix":"// before\nvar sl = handler.Get(\"/Sheet1/slicer[3]\"); // throws if <3 slicers\n\n// after\ntry { var sl = handler.Get(\"/Sheet1/slicer[3]\"); }\ncatch (ArgumentException) { /* slicer index invalid */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static int? ElementIndex(string cellRef, string element)\n{\n    var m = Regex.Match(cellRef, $@\"^{Regex.Escape(element)}\\[(\\d+)$\", RegexOptions.IgnoreCase);\n    return m.Success && int.TryParse(m.Groups[1].Value, out var i) ? i : null;\n}","tryCatchPattern":"try { return handler.Get(\"/Sheet1/slicer[3]\"); }\ncatch (ArgumentException) { /* slicer index invalid */ return null; }","preventionTips":["Slicer indices are 1-based — there is no index 0.","Confirm slicers exist on the sheet (a sheet may have timelines but no slicers).","Treat a not-found slicer as empty, not fatal."],"tags":["excel","slicer","path-index","argument-exception"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}