JetBrains/intellij-community · error · IllegalArgumentException
Row %d access failed: hierarchicalIdx cannot be empty
Error message
Row %d access failed: hierarchicalIdx cannot be empty
What it means
HierarchicalColumnsDataGridModel.validateHierarchicalIndex throws IllegalArgumentException when the hierarchical index array is non-null but empty (length == 0). An empty path addresses no column level, so traversal cannot even start; the message identifies the offending row number.
Source
Thrown at grid/core-impl/src/datagrid/HierarchicalColumnsDataGridModel.java:410
return CsvImportUtil.getPreferredTypeMergerBasedOnContent(
values, STRING_MERGER, INTEGER_MERGER, BIG_INTEGER_MERGER, DOUBLE_MERGER, BOOLEAN_MERGER);
}
private static Object getValue(GridRow row, int[] hierarchicalIdx) {
validateHierarchicalIndex(hierarchicalIdx, row.getRowNum());
return tryExtractValueByHierarchicalIndex(GridRow.getValues(row), hierarchicalIdx, row.getRowNum());
}
private static void validateHierarchicalIndex(int[] hierarchicalIdx, int rowNum) {
if (hierarchicalIdx == null) {
throw new IllegalArgumentException(
String.format("Row %d failed: hierarchicalIdx cannot be null", rowNum)
);
}
if (hierarchicalIdx.length == 0) {
throw new IllegalArgumentException(
String.format("Row %d access failed: hierarchicalIdx cannot be empty", rowNum)
);
}
}
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];View on GitHub (pinned to be881553f2)
Solutions
- Ensure every column has at least one level in its hierarchical path (top-level columns get a single-element array like [colIdx]).
- Skip hierarchical access for columns without a path and use the flat index instead.
- Assert path.length > 0 when building/validating column definitions, before any row access.
Example fix
// before
int[] idx = levels.toArray(new int[0]); // empty for top-level
getValue(row, idx);
// after
int[] idx = levels.isEmpty() ? new int[]{flatColIdx} : levels.stream().mapToInt(Integer::intValue).toArray();
getValue(row, idx); Defensive patterns
Strategy: validation
Validate before calling
if (hierarchicalIdx == null || hierarchicalIdx.length == 0) {
hierarchicalIdx = new int[]{column.getFlatIdx()};
} Type guard
static boolean isUsableIdx(@Nullable int[] idx) { return idx != null && idx.length > 0; } Prevention
- Guarantee every column definition produces at least a one-element path.
- Unit-test column builders to reject empty hierarchy paths.
When it happens
Trigger: Calling hierarchical value access with new int[0] — e.g. a column whose hierarchy path was never populated (root-only column) or a list-of-levels that was filtered to empty.
Common situations: Columns built programmatically without a hierarchy path; data-driven column definitions where the path list is empty for top-level columns and code converts it to an array unconditionally.
Related errors
- Row %d failed: hierarchicalIdx cannot be null
- Row %d access failed: %s
- Access by hierarchical idx %s failed: Index out of bounds at
- Access by hierarchical idx %s failed: Encountered a null ele
- 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/308e709a0d3d39e0.
Report an issue: GitHub.