pentaho/pentaho-kettle · error · KettleException
AvroInput.Error.UnableToParseArrayIndex
AvroInput.Error.UnableToParseArrayIndex
Error message
AvroInput.Error.UnableToParseArrayIndex
What it means
Inside the array selector '[...]', the text between the brackets must parse as an integer element index. Integer.parseInt failed on the extracted index, so convertToKettleValue throws this KettleException including the bad index string.
Solutions
- Replace the bracket content with a plain non-negative integer: '$.tags[2]'.
- Use '[*]' if you want all elements expanded rather than a specific index.
- Trim the path of stray spaces/characters inside brackets and re-save the step.
Example fix
// before $.tags[abc] // after $.tags[0]
Defensive patterns
Strategy: validation
Validate before calling
// Validate bracket content parses as an integer before configuring
java.util.regex.Matcher m = java.util.regex.Pattern.compile("\\[(.*?)\\]").matcher(path);
while (m.find()) {
String idx = m.group(1).trim();
if (!idx.equals("*") && !idx.matches("\\d+")) {
throw new IllegalArgumentException("Bad array index: [" + idx + "]");
}
} Type guard
boolean isIntegerIndex(String segment) {
if (segment == null || !segment.startsWith("[")) return false;
String idx = segment.substring(1, segment.indexOf(']')).trim();
return idx.matches("\\d+");
} Try / catch
try {
Object v = reader.convertToKettleValue(...);
} catch (KettleException e) {
if (e.getMessage().contains("UnableToParseArrayIndex")) {
// correct the index literal in the path and re-run
} else throw e;
} Prevention
- Only plain non-negative integers belong inside array brackets
- Use '[*]' when you mean 'all elements', not a keyword index
- Trim whitespace and hidden characters from hand-edited paths
When it happens
Trigger: Writing a non-numeric index such as '$.tags[*' handled elsewhere, '$.tags[abc]', '$.tags[ ]', or '$.tags[01x]' in a field path where a numeric index is required.
Common situations: Typos in hand-written paths; pasting a map key where an array index is expected; whitespace/hidden characters inside the brackets.
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
- AvroInput.Error.MalformedPathArray
- AvroInput.Error.MalformedPathArray2
- AvroInput.Error.MalformedPathMap
- AvroInput.Error.MalformedPathMap2
- AvroInput.Error.MutipleDifferentExpansions
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/757c06facc47edd1.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java:547
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;
}
Object element = array.get( arrayI );
Schema elementType = s.getElementType();
if ( element == null ) {
return null;
}View on GitHub (pinned to f3058517a1)