{"record":{"id":"ff842e818ddcb184","repo":"pentaho/pentaho-kettle","slug":"avroinput-error-malformedpathmap","errorCode":"AvroInput.Error.MalformedPathMap","errorMessage":"AvroInput.Error.MalformedPathMap","messagePattern":"AvroInput\\.Error\\.MalformedPathMap","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":443,"sourceCode":"  /**\n   * Processes a map at this point in the path.\n   *\n   * @param map           the map 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,\n                                      Map<Utf8, Object> map, Schema s, Schema defaultSchema, boolean ignoreMissing )\n    throws KettleException {\n\n    if ( map == null ) {\n      return null;\n    }\n\n    if ( avroInputField.getTempParts().size() == 0 ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"AvroInput.Error.MalformedPathMap\" ) );\n    }\n\n    String part = avroInputField.getTempParts().remove( 0 );\n    if ( !( part.charAt( 0 ) == '[' ) ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"AvroInput.Error.MalformedPathMap2\", part ) );\n    }\n\n    String key = part.substring( 1, part.indexOf( ']' ) );\n\n    if ( part.indexOf( ']' ) < part.length() - 1 ) {\n      // more dimensions to the array/map\n      part = part.substring( part.indexOf( ']' ) + 1, part.length() );\n      avroInputField.getTempParts().add( 0, part );\n    }\n\n    Object value = map.get( new Utf8( key ) );\n    if ( value == null ) {\n      return null;","sourceCodeStart":425,"sourceCodeEnd":461,"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#L425-L461","documentation":"The map-walking branch of convertToKettleValue found no remaining path parts when it needed one: the field's Avro path terminated at a MAP object but no key selector followed. The reader cannot look up a key in the map, so it throws this KettleException.","triggerScenarios":"A field path ends exactly at a map node (e.g. '$.mymap' where mymap is a map), so getTempParts() is empty when the map converter runs; or the path was consumed by earlier segments leaving nothing for the map lookup.","commonSituations":"Typing a path that stops at a map container while selecting a non-map Pentaho output type; forgetting the '[key]' bracket after a map name; schema changed so a formerly scalar field is now a map.","solutions":["Append a key selector to the path: '$.mymap[mykey]'.","If you want the whole map expanded, use the '[*]' expansion form: '$.mymap[*]'.","Verify the schema: if the field genuinely is a scalar, correct the path to point at the scalar leaf."],"exampleFix":"// before\n$.attributes\n// after (map is an object, key needed)\n$.attributes[color]","handlingStrategy":"validation","validationCode":"// Ensure a path that reaches a MAP node has a '[key]' after it\nif (schema.getField(path).schema().getType() == Schema.Type.MAP\n    && !path.matches(\".*\\\\[.+\\\\]$\")) {\n  throw new IllegalArgumentException(\"Path to map needs [key]: \" + path);\n}","typeGuard":"boolean mapPathHasKey(String path, Schema fieldSchema) {\n  return fieldSchema.getType() != Schema.Type.MAP\n      || (path != null && path.matches(\".*\\\\[.+\\\\].*$\"));\n}","tryCatchPattern":"try {\n  Object v = reader.convertToKettleValue(...);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"MalformedPathMap\")) {\n    // fix the field path to include a [key] selector\n  } else throw e;\n}","preventionTips":["Never end a field path at a map container","Always append '[key]' or use '[*]' expansion after a map node","Validate paths against the schema before running the transformation"],"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"}