{"record":{"id":"c70812a58880c445","repo":"JetBrains/intellij-community","slug":"access-by-hierarchical-idx-s-failed-encountered","errorCode":null,"errorMessage":"Access by hierarchical idx %s failed: Encountered a null element by path %s.","messagePattern":"Access by hierarchical idx (.+?) failed: Encountered a null element by path (.+?)\\.","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"grid/core-impl/src/datagrid/HierarchicalColumnsDataGridModel.java","lineNumber":445,"sourceCode":"    for (int i = 0; i < hierarchicalIdx.length; ++i) {\n      int idx = hierarchicalIdx[i];\n      if (idx < 0 || idx >= data.length) {\n        throw new IndexOutOfBoundsException(\n          String.format(\n            \"Access by hierarchical idx %s failed: Index out of bounds at element by path %s\",\n            Arrays.toString(hierarchicalIdx),\n            Arrays.toString(Arrays.copyOfRange(hierarchicalIdx, 0, i))\n          )\n        );\n      }\n\n      result = data[idx];\n\n      if (result == null && i == hierarchicalIdx.length - 1) {\n        return null;\n      }\n      else if (result == null) {\n        throw new NullPointerException(\n          String.format(\n            \"Access by hierarchical idx %s failed: Encountered a null element by path %s.\",\n            Arrays.toString(hierarchicalIdx),\n            Arrays.toString(Arrays.copyOfRange(hierarchicalIdx, 0, i))\n          )\n        );\n      }\n\n      if (result instanceof Object[] vals) {\n        data = vals;\n        continue;\n      }\n\n      if (result instanceof List<?> vals) {\n        data = vals.toArray();\n        continue;\n      }\n","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/grid/core-impl/src/datagrid/HierarchicalColumnsDataGridModel.java#L427-L463","documentation":"extractValueByHierarchicalIndex throws NullPointerException when an intermediate (non-final) level of the path resolves to null. A null is only acceptable at the last level (returned as null value); a null before more levels remain means the nesting structure is shallower than the path demands.","triggerScenarios":"Path [0, 1, 2] where data[0][1] is null but the path expects one more level; rows whose nested sub-arrays are absent for optional columns.","commonSituations":"Sparse hierarchical data (optional nested sections serialized as null); a column hierarchy deeper than some rows' actual value nesting.","solutions":["Treat null intermediates as absent values: pre-check levels and short-circuit to null when a non-final level is null.","Make the data producer materialize empty arrays instead of nulls for missing intermediate levels.","Align column-hierarchy depth with the deepest row actually present, or prune columns for levels that never exist."],"exampleFix":"// before\nObject v = getValue(row, path); // throws NPE on null intermediate\n\n// after\nObject v = hasCompletePath(row, path) ? getValue(row, path) : null;\n\n// helper\nstatic boolean hasCompletePath(GridRow row, int[] path) {\n  Object[] data = GridRow.getValues(row);\n  for (int i = 0; i < path.length - 1; i++) {\n    if (path[i] >= data.length) return false;\n    Object o = data[path[i]];\n    if (!(o instanceof Object[] a)) return false;\n    data = a;\n  }\n  return true;\n}","handlingStrategy":"validation","validationCode":"static boolean pathFullyMaterialized(Object[] values, int[] path) {\n  Object[] data = values;\n  for (int i = 0; i < path.length - 1; i++) {\n    if (path[i] >= data.length) return false;\n    Object o = data[path[i]];\n    if (!(o instanceof Object[] a)) return false;\n    data = a;\n  }\n  return true;\n}\nObject v = pathFullyMaterialized(GridRow.getValues(row), path) ? getValue(row, path) : null;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Materialize empty arrays instead of nulls for absent intermediate levels at ingestion time.","Keep column-hierarchy depth no greater than the shallowest row's real nesting, or treat null intermediates as absent values."],"tags":["datagrid","hierarchical-columns","null-safety","traversal"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}