JetBrains/intellij-community · error · IllegalStateException

Column number: %d. Error during retrieving value from nested

Error message

Column number: %d. Error during retrieving value from nested table row: column number is out of bounds.

What it means

NestedTableRow.getValue(int columnNum) throws IllegalStateException when columnNum fails myNestedTable.isValidColumnIdx, i.e. the requested column does not exist in the nested table. The wrapper refuses to forward the read to NestedTable.getValueAt with a bad index.

Source

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

  public static class NestedTableRow implements GridRow {
    private final int myRowIdx;

    private final NestedTable myNestedTable;

    NestedTableRow(int rowIdx, NestedTable table) {
      myNestedTable = table;
      if (!myNestedTable.isValidRowIdx(rowIdx)) {
        throw new IllegalStateException(
          String.format("Row index: %d. Error during nested table row creation: row index is invalid.", rowIdx));
      }
      myRowIdx = rowIdx;
    }

    @Override
    public @Nullable Object getValue(int columnNum) {
      if (!myNestedTable.isValidColumnIdx(columnNum)) {
        throw new IllegalStateException(
          String.format("Column number: %d. Error during retrieving value from nested table row: column number is out of bounds.",
                        columnNum));
      }
      return myNestedTable.getValueAt(myRowIdx, columnNum);
    }

    @Override
    public int getSize() {
      return myNestedTable.getColumnsNum();
    }

    @Override
    public void setValue(int i, @Nullable Object object) {
      if (!myNestedTable.isValidColumnIdx(i)) {
        throw new IllegalStateException(
          String.format("Column number: %d. Error during setting value in nested table row: column number is out of bounds.", i));
      }
      myNestedTable.setValueAt(myRowIdx, i, object);

View on GitHub (pinned to be881553f2)

Solutions

  1. Always bound iterations by row.getSize() (which returns the nested table's column count) instead of the outer model's column count
  2. Call myNestedTable.isValidColumnIdx(columnNum) (or row.getSize() check) before getValue
  3. Refresh the column model together with the nested table data so indexes stay consistent

Example fix

// before
Object v = row.getValue(colIdx);

// after
Object v = colIdx >= 0 && colIdx < row.getSize() ? row.getValue(colIdx) : null;
Defensive patterns

Strategy: validation

Validate before calling

Object safeGet(GridRow row, int columnNum) {
  return (columnNum >= 0 && columnNum < row.getSize()) ? row.getValue(columnNum) : null;
}

Try / catch

catch (IllegalStateException e) when(e.getMessage()!=null && e.getMessage().contains("retrieving value from nested table row")): log and return null for that cell

Prevention

When it happens

Trigger: Calling GridRow.getValue(columnNum) where columnNum < 0 or columnNum >= table.getColumnsNum(); e.g. renderer/editor querying a column number from an outer/parent model against a nested-table row.

Common situations: Column model and nested table out of sync after a column was removed; using the parent grid's column count to iterate a nested row; stale column index captured before a refresh.

Related errors


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