{"record":{"id":"dbe292d07c68c25f","repo":"JetBrains/intellij-community","slug":"row-index-d-error-during-nested-table-row-creat","errorCode":null,"errorMessage":"Row index: %d. Error during nested table row creation: row index is invalid.","messagePattern":"Row index: (.+?)\\. Error during nested table row creation: row index is invalid\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"grid/core-impl/src/datagrid/NestedTablesDataGridModel.java","lineNumber":372,"sourceCode":"\n    public GridColumn getColumn() {\n      return myColumn;\n    }\n\n    public String getColumnName() {\n      return myColumn.getName();\n    }\n  }\n\n  public static class NestedTableRow implements GridRow {\n    private final int myRowIdx;\n\n    private final NestedTable myNestedTable;\n\n    NestedTableRow(int rowIdx, NestedTable table) {\n      myNestedTable = table;\n      if (!myNestedTable.isValidRowIdx(rowIdx)) {\n        throw new IllegalStateException(\n          String.format(\"Row index: %d. Error during nested table row creation: row index is invalid.\", rowIdx));\n      }\n      myRowIdx = rowIdx;\n    }\n\n    @Override\n    public @Nullable Object getValue(int columnNum) {\n      if (!myNestedTable.isValidColumnIdx(columnNum)) {\n        throw new IllegalStateException(\n          String.format(\"Column number: %d. Error during retrieving value from nested table row: column number is out of bounds.\",\n                        columnNum));\n      }\n      return myNestedTable.getValueAt(myRowIdx, columnNum);\n    }\n\n    @Override\n    public int getSize() {\n      return myNestedTable.getColumnsNum();","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/grid/core-impl/src/datagrid/NestedTablesDataGridModel.java#L354-L390","documentation":"Thrown by the NestedTableRow constructor in NestedTablesDataGridModel when the supplied row index fails NestedTable.isValidRowIdx (negative or >= getRowsNum()). It is a fail-fast guard ensuring a GridRow wrapper can never reference a nonexistent row of the nested table.","triggerScenarios":"Calling new NestedTableRow(rowIdx, table) (directly or via model code that wraps nested-table rows) with rowIdx < 0 or rowIdx >= table.getRowsNum(); typically after the nested table shrank between reading its size and creating row wrappers.","commonSituations":"Stale row indexes cached from a previous result set; concurrent dataset refresh shrinking the nested table; off-by-one loops iterating 0..=getRowsNum().","solutions":["Re-fetch the nested table (rows/columns) right before creating row wrappers so indexes match the current getRowsNum()","Check table.isValidRowIdx(rowIdx) before constructing NestedTableRow and skip/handle invalid indexes","Audit loops for off-by-one (use '< getRowsNum()', not '<=')","If the table can mutate concurrently, synchronize access or snapshot rows under the grid model lock"],"exampleFix":"// before\nGridRow row = new NestedTablesDataGridModel.NestedTableRow(cachedIdx, table);\n\n// after\nif (table.isValidRowIdx(cachedIdx)) {\n  GridRow row = new NestedTablesDataGridModel.NestedTableRow(cachedIdx, table);\n}","handlingStrategy":"validation","validationCode":"if (table == null || !table.isValidRowIdx(rowIdx)) {\n  // refresh snapshot or skip this row\n  return;\n}\nNestedTablesDataGridModel.NestedTableRow row = new NestedTablesDataGridModel.NestedTableRow(rowIdx, table);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never cache row indexes across dataset refreshes; re-read getRowsNum() before wrapping rows","Iterate with rowIdx < table.getRowsNum(), never <=","Treat nested tables as snapshots: create all row wrappers from one consistent read"],"tags":["grid","nested-table","index-out-of-bounds","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}