{"record":{"id":"38e045d9df318f3e","repo":"pentaho/pentaho-kettle","slug":"avroinput-error-malformedpatharray","errorCode":"AvroInput.Error.MalformedPathArray","errorMessage":"AvroInput.Error.MalformedPathArray","messagePattern":"AvroInput\\.Error\\.MalformedPathArray","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":534,"sourceCode":"  /**\n   * Processes an array at this point in the path.\n   *\n   * @param array         the array to process\n   * @param s             the current schema at this point in the path\n   * @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() );","sourceCodeStart":516,"sourceCodeEnd":552,"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#L516-L552","documentation":"The array-walking branch of convertToKettleValue ran out of path parts when it reached an ARRAY node: the field path terminated at the array without an index selector. The reader cannot pick an element and throws this KettleException.","triggerScenarios":"A field path ends exactly at an array node (e.g. '$.tags' where tags is an array) with no '[n]' or '[*]' following, and no expansion handler is in play.","commonSituations":"Forgetting the index after an array name; schema changed a scalar field into an array; copy-pasting a path that stopped at the container.","solutions":["Append an index selector: '$.tags[0]'.","Use the '[*]' expansion to emit one row per element: '$.tags[*]'.","If a scalar was intended, correct the path to a scalar leaf in the schema."],"exampleFix":"// before\n$.tags\n// after\n$.tags[0]","handlingStrategy":"validation","validationCode":"// A path that reaches an ARRAY node must continue with [n] or [*]\nif (fieldSchema.getType() == Schema.Type.ARRAY\n    && !path.matches(\".*\\\\[(\\\\d+|\\\\*)\\\\]$\")) {\n  throw new IllegalArgumentException(\"Array path needs an index or [*]: \" + path);\n}","typeGuard":"boolean arrayPathIndexed(String path, Schema fieldSchema) {\n  return fieldSchema.getType() != Schema.Type.ARRAY\n      || (path != null && path.matches(\".*\\\\[(\\\\d+|\\\\*)\\\\].*$\"));\n}","tryCatchPattern":"try {\n  Object v = reader.convertToKettleValue(...);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"MalformedPathArray\")) {\n    // append [index] or switch to [*] expansion\n  } else throw e;\n}","preventionTips":["Never end a field path at an array container","Append '[n]' for a specific element or '[*]' for expansion","Re-validate paths whenever the schema changes a field to an array"],"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"}