pentaho/pentaho-kettle · error · KettleException

AvroInput.Error.InvalidPath

Error message

AvroInput.Error.InvalidPath

What it means

Kettle exception thrown by convertToKettleValue when a path part of an AvroInputField begins with '['. Array/index selectors are only valid when attached to the end of a named field part (e.g. 'myfield[0]'), not as a standalone leading token. The path syntax is invalid for record traversal.

Solutions

  1. Remove the standalone '[...]' segment; put the array index on the end of the field name instead, e.g. 'mylist[0]'.
  2. Verify the path uses Avro Input syntax (dot-separated field names with trailing [n] indexes), not JSONPath.
  3. Check for stray leading brackets from copy/paste or split characters like '.' producing empty/bracket-only parts.
  4. Use the step's schema-discovery path preview to build the path instead of typing it.

Example fix

// before
Field path: items.[0].sku
// after
Field path: items[0].sku
Defensive patterns

Strategy: validation

Validate before calling

// Reject standalone bracket segments before passing the path to the step
if (java.util.Arrays.stream(path.split("\\.")).anyMatch(p -> p.startsWith("["))) {
  throw new IllegalArgumentException("Array index must follow a field name: use 'field[0]', not '.[0]'");
}

Try / catch

try {
  runTransformation();
} catch (KettleException e) {
  if (e.getMessage().contains("InvalidPath")) {
    logError("Fix path syntax: indexes go on field names (items[0]), not as separate segments", e);
  }
}

Prevention

When it happens

Trigger: The configured path contains an array index segment placed before any field name — e.g. path 'myfield.[0]' or a path split producing a part starting with '[' — so after remove(0) the part charAt(0) is '['.

Common situations: Users hand-writing paths for Avro arrays and prefixing the index; pasting JSONPath-style syntax (root '$[0]') into the Avro Input path box; paths built by script with a stray leading bracket.

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/c5676df8d4d18fde. Report an issue: GitHub.

Appendix: source

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

   * @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.Record record, Schema s,
                                     Schema defaultSchema, boolean ignoreMissing )
    throws KettleException {

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

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

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

    if ( part.indexOf( '[' ) > 0 ) {
      String arrayPart = part.substring( part.indexOf( '[' ) );
      part = part.substring( 0, part.indexOf( '[' ) );

      // put the array section back into location zero
      avroInputField.getTempParts().add( 0, arrayPart );
    }

    // part is a named field of the record
    Schema.Field fieldS = s.getField( part );
    if ( fieldS == null && !ignoreMissing ) {
      throw new KettleException( BaseMessages.getString( PKG, "AvroInput.Error.NonExistentField", part ) );
    }
    Object field = record.get( part );

View on GitHub (pinned to f3058517a1)