pentaho/pentaho-kettle · error · KettleException

AvroInput.Error.MalformedPathArray2

AvroInput.Error.MalformedPathArray2

Error message

AvroInput.Error.MalformedPathArray2

What it means

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.

Solutions

  1. Use an integer index in brackets: '$.tags[0]'.
  2. If the element should be selected per-row, use the '[*]' expansion instead.
  3. Confirm the node type in the schema: if it is actually a MAP, use '[key]' notation; if a RECORD, use dot notation.

Example fix

// before
$.tags.first
// after
$.tags[0]
Defensive patterns

Strategy: validation

Validate before calling

// Segment following an array must be a bracketed integer index or [*]
String[] parts = path.split("\\.");
String last = parts[parts.length - 1];
if (nodeIsArray(parentSchema) && !last.matches("\\[(\\d+|\\*)\\].*")) {
  throw new IllegalArgumentException("Array access must be [n] or [*]: " + last);
}

Type guard

boolean isArraySelector(String segment) {
  return segment != null && segment.matches("\\[(\\d+|\\*)\\].*");
}

Try / catch

try {
  Object v = reader.convertToKettleValue(...);
} catch (KettleException e) {
  if (e.getMessage().contains("MalformedPathArray2")) {
    // replace the bad segment with a bracketed index
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Confusing array syntax with map syntax (maps need '[key]', arrays need '[n]'); paths copied from tools that auto-index arrays.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/2d75f1fc7786b8cc. Report an issue: GitHub.

Appendix: source

Thrown at plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java:539

   * @param ignoreMissing true if null is to be returned for user fields that don't appear in the schema
   * @return the field value or null for out-of-bounds array indexes, non-existent map keys or unsupported avro types.
   * @throws KettleException if a problem occurs
   */
  public Object convertToKettleValue(AvroInputField avroInputField, GenericData.Array array, Schema s,
                                     Schema defaultSchema, boolean ignoreMissing )
    throws KettleException {

    if ( array == null ) {
      return null;
    }

    if ( avroInputField.getTempParts().size() == 0 ) {
      throw new KettleException( BaseMessages.getString( PKG, "AvroInput.Error.MalformedPathArray" ) );
    }

    String part = avroInputField.getTempParts().remove( 0 );
    if ( !( part.charAt( 0 ) == '[' ) ) {
      throw new KettleException( BaseMessages.getString( PKG, "AvroInput.Error.MalformedPathArray2", part ) );
    }

    String index = part.substring( 1, part.indexOf( ']' ) );
    int arrayI = 0;
    try {
      arrayI = Integer.parseInt( index.trim() );
    } catch ( NumberFormatException e ) {
      throw new KettleException( BaseMessages.getString( PKG, "AvroInput.Error.UnableToParseArrayIndex", index ) );
    }

    if ( part.indexOf( ']' ) < part.length() - 1 ) {
      // more dimensions to the array
      part = part.substring( part.indexOf( ']' ) + 1, part.length() );
      avroInputField.getTempParts().add( 0, part );
    }

    if ( arrayI >= array.size() || arrayI < 0 ) {
      return null;

View on GitHub (pinned to f3058517a1)