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
- Call isValidColumnIdx(colIdx) on the wrapper before getColumnType.
- Invalidate cached column indexes on column-structure change events.
- 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
- Invalidate column-index caches on setColumns/clearColumns.
- Never pass nested-table indexes to the top-level wrapper or vice versa.
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
- "Given column index " + colIdx + " is not valid."
- Invalid given row index: %d. Index should be in range from 0
- "Unable to set value. No GridRow found at row index: " + row
- The setColumns operation can only be performed on top-level
- "Starting index " + startingIdx + " is greater than the tota
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/3431d9460e21b59f.
Report an issue: GitHub.