JetBrains/intellij-community · error · IllegalArgumentException
Row %d failed: hierarchicalIdx cannot be null
Error message
Row %d failed: hierarchicalIdx cannot be null
What it means
HierarchicalColumnsDataGridModel.getValue(row, hierarchicalIdx) throws IllegalArgumentException when the hierarchical column path passed by the caller is null. The path (int[] of nesting levels) is mandatory: validateHierarchicalIndex checks it before any traversal of the row's nested value arrays.
Source
Thrown at grid/core-impl/src/datagrid/HierarchicalColumnsDataGridModel.java:404
Object value = tryExtractValueByHierarchicalIndex(rowValues, columnPath, rowIdx+1);
return value == null ? null : value.toString();
})
.limit(200)
.collect(Collectors.toList());
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);
}
}View on GitHub (pinned to be881553f2)
Solutions
- Compute the hierarchical index from the column (e.g. column's path in the columns hierarchy) and pass a non-null int[].
- Add a null check at the call site and fail fast with context about which column produced the null path.
- For flat access, use the top-level value APIs instead of hierarchical ones.
Example fix
// before Object v = getValue(row, null); // after int[] path = column.getHierarchicalIdx(); // never null for live columns Object v = getValue(row, path);
Defensive patterns
Strategy: validation
Validate before calling
if (hierarchicalIdx == null) throw new IllegalArgumentException("hierarchicalIdx required for column " + column.getName()); Type guard
static boolean hasHierarchicalIdx(@Nullable int[] idx) { return idx != null; } Prevention
- Derive the path from the live column object; never hand-build null placeholders.
- Fail fast at the call boundary with the column identity in the message.
When it happens
Trigger: Calling getValue/setValue style accessors with a null int[] hierarchical index — commonly a caller that resolved the path from a GridColumn whose hierarchy was not initialized, or a default-parameter null slipping through.
Common situations: New code paths (custom renderers, exporters) that assume flat columns and pass null; refactoring that makes path computation optional without a fallback.
Related errors
- Row %d access failed: hierarchicalIdx cannot be empty
- 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/44f3eea1e5b9be0d.
Report an issue: GitHub.