JetBrains/intellij-community · error · IllegalStateException

"Given column index " + colIdx + " is not valid."

Error message

"Given column index " + colIdx + " is not valid."

What it means

GridWrapperNestedTable.getColumnType(int) throws IllegalStateException when colIdx fails the delegated isValidColumnIdx check (ModelIndex.forColumn conversion + model's own bounds check). Unlike DynamicNestedTable which uses IllegalArgumentException, this wrapper signals a model-state problem.

Source

Thrown at grid/core-impl/src/datagrid/GridWrapperNestedTable.java:71

  @Override
  public int getColumnsNum() {
    return myGridModel.getColumnCount();
  }

  @Override
  public boolean isValidRowIdx(int rowIdx) {
    return myGridModel.isValidRowIdx(ModelIndex.forRow(myGridModel, rowIdx));
  }

  @Override
  public boolean isValidColumnIdx(int colIdx) {
    return myGridModel.isValidColumnIdx(ModelIndex.forColumn(myGridModel, colIdx));
  }

  @Override
  public int getColumnType(int colIdx) {
    if (!isValidColumnIdx(colIdx)) {
      throw new IllegalStateException("Given column index " + colIdx + " is not valid.");
    }
    return Objects.requireNonNull(myGridModel.getColumn(ModelIndex.forColumn(myGridModel, colIdx))).getType();
  }

  @Override
  public String getColumnTypeName(int colIdx) {
    if (!isValidColumnIdx(colIdx)) {
      throw new IllegalStateException("Given column index " + colIdx + " is not valid.");
    }
    return Objects.requireNonNull(myGridModel.getColumn(ModelIndex.forColumn(myGridModel, colIdx))).getTypeName();
  }

  @Override
  public String getColumnName(int colIdx) {
    if (!isValidColumnIdx(colIdx)) {
      throw new IllegalStateException("Given column index " + colIdx + " is not valid.");
    }
    return Objects.requireNonNull(myGridModel.getColumn(ModelIndex.forColumn(myGridModel, colIdx))).getName();

View on GitHub (pinned to be881553f2)

Solutions

  1. Call isValidColumnIdx(colIdx) on the wrapper before getColumnType.
  2. Invalidate cached column indexes on column-structure change events.
  3. Resolve columns by GridColumn identity instead of raw int where possible.

Example fix

// before
int type = wrapper.getColumnType(colIdx);

// after
if (wrapper.isValidColumnIdx(colIdx)) {
  int type = wrapper.getColumnType(colIdx);
}
Defensive patterns

Strategy: validation

Validate before calling

int type = wrapper.isValidColumnIdx(colIdx) ? wrapper.getColumnType(colIdx) : -1;

Prevention

When it happens

Trigger: Calling getColumnType with a column index valid for a different column provider, or after the underlying model's columns changed (setColumns/clearColumns) while an old index was retained.

Common situations: Renderer or type-based formatting code holding a column index across a schema change; mixing nested-table column indexes with top-level grid column indexes.

Related errors


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