pentaho/pentaho-kettle · error · KettleException

AvroInput.Error.MalformedPathMap2

AvroInput.Error.MalformedPathMap2

Error message

AvroInput.Error.MalformedPathMap2

What it means

The map-walking branch of convertToKettleValue popped the next path part and expects it to be a bracketed key selector like '[mykey]'. The part did not start with '[', so it is not a valid map key accessor; the reader throws this KettleException naming the offending part.

Solutions

  1. Replace the dot-notation key with bracket notation: '$.mymap[color]'.
  2. If the target is actually a RECORD, fix the path/schema so the reader uses the record branch (dot access works only for records).
  3. Regenerate the schema and confirm node types; adjust the field path in the step definition accordingly.

Example fix

// before
$.mymap.color
// after
$.mymap[color]
Defensive patterns

Strategy: validation

Validate before calling

// The segment after a map must be bracketed, not dotted
String[] parts = path.split("\\.");
String last = parts[parts.length - 1];
if (nodeIsMap(parentSchema) && !last.startsWith("[")) {
  throw new IllegalArgumentException("Map access must use [key] syntax: " + last);
}

Type guard

boolean isBracketed(String segment) {
  return segment != null && segment.startsWith("[") && segment.endsWith("]");
}

Try / catch

try {
  Object v = reader.convertToKettleValue(...);
} catch (KettleException e) {
  if (e.getMessage().contains("MalformedPathMap2")) {
    // convert dot notation to bracket notation for that segment
  } else throw e;
}

Prevention

When it happens

Trigger: A path segment following a map node is a plain name (dot notation) instead of a '[key]' bracket, e.g. '$.mymap.color' or '$.mymap.color' where the schema at that point is a MAP. The message includes the bad segment.

Common situations: Assuming Avro maps behave like records and using dot-notation keys; paths copied from JSON tooling that accept dot access for maps.

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

Appendix: source

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

   * @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,
                                      Map<Utf8, Object> map, Schema s, Schema defaultSchema, boolean ignoreMissing )
    throws KettleException {

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

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

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

    String key = part.substring( 1, part.indexOf( ']' ) );

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

    Object value = map.get( new Utf8( key ) );
    if ( value == null ) {
      return null;
    }

    Schema valueType = s.getValueType();

    if ( valueType.getType() == Schema.Type.UNION ) {

View on GitHub (pinned to f3058517a1)