{"record":{"id":"2d75f1fc7786b8cc","repo":"pentaho/pentaho-kettle","slug":"avroinput-error-malformedpatharray2","errorCode":"AvroInput.Error.MalformedPathArray2","errorMessage":"AvroInput.Error.MalformedPathArray2","messagePattern":"AvroInput\\.Error\\.MalformedPathArray2","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java","lineNumber":539,"sourceCode":"   * @param ignoreMissing true if null is to be returned for user fields that don't appear in the schema\n   * @return the field value or null for out-of-bounds array indexes, non-existent map keys or unsupported avro types.\n   * @throws KettleException if a problem occurs\n   */\n  public Object convertToKettleValue(AvroInputField avroInputField, GenericData.Array array, Schema s,\n                                     Schema defaultSchema, boolean ignoreMissing )\n    throws KettleException {\n\n    if ( array == null ) {\n      return null;\n    }\n\n    if ( avroInputField.getTempParts().size() == 0 ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"AvroInput.Error.MalformedPathArray\" ) );\n    }\n\n    String part = avroInputField.getTempParts().remove( 0 );\n    if ( !( part.charAt( 0 ) == '[' ) ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"AvroInput.Error.MalformedPathArray2\", part ) );\n    }\n\n    String index = part.substring( 1, part.indexOf( ']' ) );\n    int arrayI = 0;\n    try {\n      arrayI = Integer.parseInt( index.trim() );\n    } catch ( NumberFormatException e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"AvroInput.Error.UnableToParseArrayIndex\", index ) );\n    }\n\n    if ( part.indexOf( ']' ) < part.length() - 1 ) {\n      // more dimensions to the array\n      part = part.substring( part.indexOf( ']' ) + 1, part.length() );\n      avroInputField.getTempParts().add( 0, part );\n    }\n\n    if ( arrayI >= array.size() || arrayI < 0 ) {\n      return null;","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java#L521-L557","documentation":"The array-walking branch of convertToKettleValue popped the next path part and requires it to be a bracketed index selector like '[3]'. The part did not begin with '[', so it is not a valid array accessor; this KettleException is thrown with the offending segment.","triggerScenarios":"Using dot or bare-name access after an array node, e.g. '$.tags.first' or '$.tags.length', where the schema at that point is an ARRAY.","commonSituations":"Confusing array syntax with map syntax (maps need '[key]', arrays need '[n]'); paths copied from tools that auto-index arrays.","solutions":["Use an integer index in brackets: '$.tags[0]'.","If the element should be selected per-row, use the '[*]' expansion instead.","Confirm the node type in the schema: if it is actually a MAP, use '[key]' notation; if a RECORD, use dot notation."],"exampleFix":"// before\n$.tags.first\n// after\n$.tags[0]","handlingStrategy":"validation","validationCode":"// Segment following an array must be a bracketed integer index or [*]\nString[] parts = path.split(\"\\\\.\");\nString last = parts[parts.length - 1];\nif (nodeIsArray(parentSchema) && !last.matches(\"\\\\[(\\\\d+|\\\\*)\\\\].*\")) {\n  throw new IllegalArgumentException(\"Array access must be [n] or [*]: \" + last);\n}","typeGuard":"boolean isArraySelector(String segment) {\n  return segment != null && segment.matches(\"\\\\[(\\\\d+|\\\\*)\\\\].*\");\n}","tryCatchPattern":"try {\n  Object v = reader.convertToKettleValue(...);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"MalformedPathArray2\")) {\n    // replace the bad segment with a bracketed index\n  } else throw e;\n}","preventionTips":["Use '[n]' for arrays and '[key]' for maps - do not mix them","Dot notation is only valid for record fields","Keep a path cheat-sheet next to step definitions"],"tags":["avro","path","malformed-path","pdi"],"backgroundTag":"invalid-argument-format","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}