JetBrains/intellij-community · error · IndexOutOfBoundsException
Access by hierarchical idx %s failed: Index out of bounds at
Error message
Access by hierarchical idx %s failed: Index out of bounds at element by path %s
What it means
Thrown by extractValueByHierarchicalIndex when some level of the hierarchical index is negative or >= the length of the value array at that nesting level. The message includes the full index path and the prefix path at which the failure occurred, making it possible to see exactly which level is out of range.
Source
Thrown at grid/core-impl/src/datagrid/HierarchicalColumnsDataGridModel.java:430
);
}
}
private static @Nullable Object tryExtractValueByHierarchicalIndex(Object[] topLevelValues, int[] hierarchicalIdx, int rowNum) {
try {
return extractValueByHierarchicalIndex(topLevelValues, hierarchicalIdx);
} catch (IndexOutOfBoundsException | NullPointerException | IllegalArgumentException e) {
throw new RuntimeException(String.format("Row %d access failed: %s", rowNum, e.getMessage()), e);
}
}
public static Object extractValueByHierarchicalIndex(Object[] topLevelValues, int[] hierarchicalIdx) {
Object result = null;
Object[] data = topLevelValues;
for (int i = 0; i < hierarchicalIdx.length; ++i) {
int idx = hierarchicalIdx[i];
if (idx < 0 || idx >= data.length) {
throw new IndexOutOfBoundsException(
String.format(
"Access by hierarchical idx %s failed: Index out of bounds at element by path %s",
Arrays.toString(hierarchicalIdx),
Arrays.toString(Arrays.copyOfRange(hierarchicalIdx, 0, i))
)
);
}
result = data[idx];
if (result == null && i == hierarchicalIdx.length - 1) {
return null;
}
else if (result == null) {
throw new NullPointerException(
String.format(
"Access by hierarchical idx %s failed: Encountered a null element by path %s.",
Arrays.toString(hierarchicalIdx),View on GitHub (pinned to be881553f2)
Solutions
- Rebuild the hierarchical index from the live column hierarchy right before access.
- Invalidate cached paths whenever columns are set/cleared or the model fires a structure change.
- For heterogeneous data, ensure the column hierarchy and value arrays are produced by the same conversion step.
Example fix
// before Object v = getValue(row, cachedPath); // after int[] path = currentColumnsModel.idxFor(column); // derived from live hierarchy Object v = getValue(row, path);
Defensive patterns
Strategy: validation
Validate before calling
static boolean pathInBounds(Object[] values, int[] path) {
Object[] data = values;
for (int idx : path) {
if (idx < 0 || idx >= data.length) return false;
Object o = data[idx];
if (o instanceof Object[] a) data = a;
else if (o instanceof List<?> l) data = l.toArray();
else return true; // leaf
}
return true;
} Prevention
- Generate hierarchical indexes and row value arrays in one conversion step so they cannot diverge.
- Drop cached paths on any column-structure change.
When it happens
Trigger: Passing a path built against a different nesting structure — e.g. [1, 3] where level-1 arrays only have 2 elements; paths computed from column positions that no longer match the row's value layout after a reload.
Common situations: Rows with heterogeneous nesting depth; hierarchical columns edited (column moved/removed) so cached paths desync from GridRow.getValues layout.
Related errors
- Row %d access failed: %s
- Access by hierarchical idx %s failed: Encountered a null ele
- Row %d failed: hierarchicalIdx cannot be null
- Row %d access failed: hierarchicalIdx cannot be empty
- Access by hierarchical idx %s failed: Encountered an unexpec
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/ecfc6ddf022907d2.
Report an issue: GitHub.