{"record":{"id":"550be0b70d378966","repo":"iOfficeAI/OfficeCLI","slug":"table-tidx-has-no-definition","errorCode":null,"errorMessage":"Table {tIdx} has no definition","messagePattern":"Table (.+?) has no definition","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Query.cs","lineNumber":825,"sourceCode":"        var tableMatch = Regex.Match(cellRef, @\"^table\\[(\\d+)\\]$\", RegexOptions.IgnoreCase);\n        if (tableMatch.Success)\n        {\n            var tableIdx = int.Parse(tableMatch.Groups[1].Value);\n            return TableToNode(sheetNameFromPath, worksheet, tableIdx, depth);\n        }\n\n        // Table column path: /Sheet1/table[N]/columns[M] or /column[M]\n        var tableColMatch = Regex.Match(cellRef,\n            @\"^table\\[(\\d+)\\]/(?:columns|column)\\[(\\d+)\\]$\", RegexOptions.IgnoreCase);\n        if (tableColMatch.Success)\n        {\n            var tIdx = int.Parse(tableColMatch.Groups[1].Value);\n            var cIdx = int.Parse(tableColMatch.Groups[2].Value);\n            var tParts = worksheet.TableDefinitionParts.ToList();\n            if (tIdx < 1 || tIdx > tParts.Count)\n                throw new ArgumentException($\"Table index {tIdx} out of range (1..{tParts.Count})\");\n            var tbl = tParts[tIdx - 1].Table\n                ?? throw new ArgumentException($\"Table {tIdx} has no definition\");\n            var tCols = tbl.GetFirstChild<TableColumns>()?.Elements<TableColumn>().ToList();\n            if (tCols == null || cIdx < 1 || cIdx > tCols.Count)\n                throw new ArgumentException($\"Column index {cIdx} out of range (1..{tCols?.Count ?? 0})\");\n            var tCol = tCols[cIdx - 1];\n            var tcNode = new DocumentNode\n            {\n                Path = $\"/{sheetNameFromPath}/table[{tIdx}]/columns[{cIdx}]\",\n                Type = \"tableColumn\",\n                Text = tCol.Name?.Value ?? \"\"\n            };\n            tcNode.Format[\"name\"] = tCol.Name?.Value ?? \"\";\n            if (tCol.Id?.Value != null) tcNode.Format[\"id\"] = tCol.Id.Value;\n            if (tCol.TotalsRowFunction?.HasValue == true)\n                // Open XML SDK v3 EnumValue<T>.ToString() returns\n                // \"TotalsRowFunctionValues { }\" — use InnerText for the\n                // OOXML-canonical lowercase token. CONSISTENCY(enum-innertext).\n                tcNode.Format[\"totalFunction\"] = tCol.TotalsRowFunction.InnerText;\n            if (tCol.TotalsRowLabel?.Value != null)","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Query.cs#L807-L843","documentation":"Thrown when TableDefinitionParts[N-1].Table is null — the part exists but carries no <table> definition element. This signals a corrupt or incompletely-written table part (e.g. a dangling relationship to an empty/broken part). The code surfaces it as an explicit ArgumentException rather than NullReferenceException-ing on the subsequent access.","triggerScenarios":"handler.Get(\"/Sheet1/table[1]/columns[1]\") when the table's definition part is present but its Table element is null — typically a hand-edited or tool-corrupted .xlsx where the table part was emptied.","commonSituations":"Corrupt workbook where a table relationship dangles. A write/merge tool that created the part but not the definition. A renamed/moved table whose part wasn't updated.","solutions":["Repair the workbook (re-save in Excel, or rebuild the table definition) so the part has a <table> element.","Drop and re-add the table via the Add API.","try/catch(ArgumentException) and skip the broken table."],"exampleFix":"// before\nvar col = handler.Get(\"/Sheet1/table[1]/columns[1]\"); // throws: part has no <table>\n\n// after\ntry { var col = handler.Get(\"/Sheet1/table[1]/columns[1]\"); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"no definition\")) { /* table part corrupt; repair or skip */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return handler.Get(\"/Sheet1/table[1]/columns[1]\"); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"no definition\")) { /* corrupt table part — repair or skip */ return null; }","preventionTips":["A dangling table relationship produces a part with no <table> element — re-save the workbook in Excel to repair.","Drop and re-add the table via the Add API if the part is corrupt.","Don't treat a missing definition as an index bug — it's a data-integrity issue."],"tags":["excel","tables","corrupt-part","argument-exception"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}