JetBrains/intellij-community · error · IllegalStateException

Column index: . Error during nested table column creation…

Error message

Column index: %d. Error during nested table column creation: column index is out of bounds.

What it means

The NestedTableColumn constructor throws IllegalStateException when the given column index fails NestedTable.isValidColumnIdx (negative or >= getColumnsNum()). It prevents creating a GridColumn wrapper for a column the nested table does not have.

Solutions

  1. Check table.isValidColumnIdx(columnIdx) before constructing NestedTableColumn
  2. Rebuild column wrappers from the same table snapshot used to read getColumnsNum()
  3. Handle the zero-column nested table case explicitly instead of wrapping columns unconditionally

Example fix

// before
GridColumn col = new NestedTablesDataGridModel.NestedTableColumn(idx, table);

// after
if (table.isValidColumnIdx(idx)) {
  GridColumn col = new NestedTablesDataGridModel.NestedTableColumn(idx, table);
}
Defensive patterns

Strategy: validation

Validate before calling

if (table.isValidColumnIdx(columnIdx)) {
  GridColumn col = new NestedTablesDataGridModel.NestedTableColumn(columnIdx, table);
}

Prevention

When it happens

Trigger: Constructing new NestedTableColumn(columnIdx, table) with columnIdx < 0 or >= table.getColumnsNum(); common when a column-model builder iterates a stale column count or the nested table has zero columns.

Common situations: Column hierarchy (StaticNestedTable columns) changed between building the column list and wrapping columns; empty nested table while code assumes at least one column; index confusion between hierarchical column position and flat column number.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/fde7ece56d061a3b. Report an issue: GitHub.

Appendix: source

Thrown at grid/core-impl/src/datagrid/NestedTablesDataGridModel.java:420

    @Override
    public int getRowNum() {
      return myNestedTable.getRowNum(myRowIdx);
    }
  }

  public static class NestedTableColumn implements GridColumn {
    private final int myColumnIdx;

    private final NestedTable myNestedTable;

    private int myType = Integer.MAX_VALUE;

    private String myTypeName = null;

    NestedTableColumn(int columnIdx, NestedTable table) {
      myNestedTable = table;
      if (!myNestedTable.isValidColumnIdx(columnIdx)) {
        throw new IllegalStateException(
          String.format("Column index: %d. Error during nested table column creation: column index is out of bounds.", columnIdx));
      }
      myColumnIdx = columnIdx;
    }

    @Override
    public int getColumnNumber() {
      return myColumnIdx;
    }

    @Override
    public int getType() {
      if (myType == Integer.MAX_VALUE) {
        myType = myNestedTable.getColumnType(myColumnIdx);
      }
      return myType;
    }

View on GitHub (pinned to be881553f2)