JetBrains/intellij-community · error · NullPointerException
Access by hierarchical idx
Error message
Access by hierarchical idx %s failed: Encountered an unexpected nested collection by path %s. Only arrays or lists are allowed as nested collections
What it means
extractValueByHierarchicalIndex accepts Object[] and List as nested collections but throws (as NullPointerException) when a path level resolves to some other Collection type (e.g. Set, Queue, Collection from a stream). The message states that only arrays or lists are allowed as nested collections.
Solutions
- Convert nested collections to List or Object[] when building row values (e.g. new ArrayList<>(set) or set.toArray()).
- Add an ingestion-time check rejecting/wrapping non-list Collections.
- If ordering is irrelevant, sort deterministically before converting to keep paths stable.
Example fix
// before values[0] = someSet; // Set at nested level // after values[0] = new ArrayList<>(someSet); // List is supported
Defensive patterns
Strategy: type-guard
Validate before calling
Object v = values[level];
if (v instanceof Collection c && !(v instanceof List)) {
v = new ArrayList<>(c); // normalize to supported List
values[level] = v;
} Type guard
static boolean isSupportedNestedValue(Object o) {
return o == null || o instanceof Object[] || o instanceof List || !(o instanceof Collection);
} Prevention
- Normalize all nested collections to List/Object[] when constructing row values.
- Add ingestion-time assertions that reject Set/Queue at nested levels.
When it happens
Trigger: Row values containing a Set/HashSet or other non-list Collection at a level the hierarchical path traverses; converting JSON/DB data where a nested field was materialized as a Set.
Common situations: Data ingestion code that stores arbitrary Java collections into row values; version changes where a producer switched from List to Set for nested elements.
Related errors
- Access by hierarchical idx
- Access by hierarchical idx
- Row access failed: hierarchicalIdx cannot be empty
- Row access failed
- Row failed: hierarchicalIdx cannot be null
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/991d8f6d3668847e.
Report an issue: GitHub.
Appendix: source
Thrown at grid/core-impl/src/datagrid/HierarchicalColumnsDataGridModel.java:465
"Access by hierarchical idx %s failed: Encountered a null element by path %s.",
Arrays.toString(hierarchicalIdx),
Arrays.toString(Arrays.copyOfRange(hierarchicalIdx, 0, i))
)
);
}
if (result instanceof Object[] vals) {
data = vals;
continue;
}
if (result instanceof List<?> vals) {
data = vals.toArray();
continue;
}
if (result instanceof Collection) {
throw new NullPointerException(
String.format(
"Access by hierarchical idx %s failed: Encountered an unexpected nested collection by path %s. Only arrays or lists are allowed as nested collections",
Arrays.toString(hierarchicalIdx),
Arrays.toString(Arrays.copyOfRange(hierarchicalIdx, 0, i))
)
);
}
break;
}
return result;
}
private static int[] addIntToArray(int[] array, int value) {
int[] newArray = new int[array.length + 1];
System.arraycopy(array, 0, newArray, 0, array.length);
newArray[array.length] = value;View on GitHub (pinned to be881553f2)