JetBrains/intellij-community · error · IllegalStateException
"Given column index " + colIdx + " is not valid."
Error message
"Given column index " + colIdx + " is not valid."
What it means
StaticNestedTable.getColumnType(colIdx) throws IllegalStateException when colIdx fails isValidColumnIdx (colIdx > -1 && colIdx < getColumnsNum()). Column type is computed via TypeMerger over the rows data, so a valid index is a hard precondition.
Source
Thrown at grid/core-impl/src/datagrid/StaticNestedTable.java:77
@Override
public int getColumnsNum() {
return myRowsValues.length > 0 ? myRowsValues[0].length : 0;
}
@Override
public boolean isValidRowIdx(int rowIdx) {
return rowIdx > -1 && rowIdx < getRowsNum();
}
@Override
public boolean isValidColumnIdx(int colIdx) {
return colIdx > -1 && colIdx < getColumnsNum();
}
@Override
public int getColumnType(int colIdx) {
if (!isValidColumnIdx(colIdx)) {
throw new IllegalStateException("Given column index " + colIdx + " is not valid.");
}
TypeMerger merger = determineColumnType(myRowsValues, new int[] { colIdx });
return DocumentDataHookUp.DataMarkup.getType(merger);
}
@Override
public String getColumnTypeName(int colIdx) {
if (!isValidColumnIdx(colIdx)) {
throw new IllegalStateException("Given column index " + colIdx + " is not valid.");
}
TypeMerger merger = determineColumnType(myRowsValues, new int[] { colIdx });
return merger.getName();
}
@Override
public String getColumnName(int colIdx) {View on GitHub (pinned to be881553f2)
Solutions
- Call isValidColumnIdx(colIdx) (or compare against getColumnsNum()) before getColumnType
- Derive column indexes from myColumnsHierarchy.getChildren() size / the same snapshot used to build the table
- Fix off-by-one in the caller's column loop
Example fix
// before int type = table.getColumnType(colIdx); // after int type = table.isValidColumnIdx(colIdx) ? table.getColumnType(colIdx) : -1;
Defensive patterns
Strategy: validation
Validate before calling
int safeType = table.isValidColumnIdx(colIdx) ? table.getColumnType(colIdx) : -1;
Prevention
- Guard every metadata query (type/name) with isValidColumnIdx
- Use one snapshot for both loop bounds and metadata reads
- Unit-test the zero-column and single-column table cases
When it happens
Trigger: Calling getColumnType(colIdx) with a negative index or an index >= the number of columns in the static nested table (built from myColumnsHierarchy).
Common situations: Caller uses the parent grid's column count instead of the nested table's; column hierarchy built from one dataset but queried with indexes from another; edge case of an empty columns hierarchy.
Related errors
- Column number: %d. Error during retrieving value from nested
- Column number: %d. Error during setting value in nested tabl
- Column index: %d. Error during nested table column creation:
- Row index: %d. Error during nested table row creation: row i
- The %s does not support rows addition, use another implement
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/b04f2fb834359e49.
Report an issue: GitHub.