{"record":{"id":"b04f2fb834359e49","repo":"JetBrains/intellij-community","slug":"given-column-index-colidx-is-not-valid-b04f2f","errorCode":null,"errorMessage":"\"Given column index \" + colIdx + \" is not valid.\"","messagePattern":"\"Given column index \" \\+ colIdx \\+ \" is not valid\\.\"","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"grid/core-impl/src/datagrid/StaticNestedTable.java","lineNumber":77,"sourceCode":"  @Override\n  public int getColumnsNum() {\n    return myRowsValues.length > 0 ? myRowsValues[0].length : 0;\n  }\n\n  @Override\n  public boolean isValidRowIdx(int rowIdx) {\n    return rowIdx > -1 && rowIdx < getRowsNum();\n  }\n\n  @Override\n  public boolean isValidColumnIdx(int colIdx) {\n    return colIdx > -1 && colIdx < getColumnsNum();\n  }\n\n  @Override\n  public int getColumnType(int colIdx) {\n    if (!isValidColumnIdx(colIdx)) {\n      throw new IllegalStateException(\"Given column index \" + colIdx + \" is not valid.\");\n    }\n\n    TypeMerger merger = determineColumnType(myRowsValues, new int[] { colIdx });\n    return DocumentDataHookUp.DataMarkup.getType(merger);\n  }\n\n  @Override\n  public String getColumnTypeName(int colIdx) {\n    if (!isValidColumnIdx(colIdx)) {\n      throw new IllegalStateException(\"Given column index \" + colIdx + \" is not valid.\");\n    }\n\n    TypeMerger merger = determineColumnType(myRowsValues, new int[] { colIdx });\n    return merger.getName();\n  }\n\n  @Override\n  public String getColumnName(int colIdx) {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/grid/core-impl/src/datagrid/StaticNestedTable.java#L59-L95","documentation":"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.","triggerScenarios":"Calling getColumnType(colIdx) with a negative index or an index >= the number of columns in the static nested table (built from myColumnsHierarchy).","commonSituations":"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.","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"],"exampleFix":"// before\nint type = table.getColumnType(colIdx);\n\n// after\nint type = table.isValidColumnIdx(colIdx) ? table.getColumnType(colIdx) : -1;","handlingStrategy":"validation","validationCode":"int safeType = table.isValidColumnIdx(colIdx) ? table.getColumnType(colIdx) : -1;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["grid","nested-table","column-index","type-inference","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}