apache/flink · error · IndexOutOfBoundsException
{pos}
Error message
{pos} What it means
Tuple8.getField(int pos) throws IndexOutOfBoundsException when pos is outside 0..7. Tuple8 is the largest Java tuple arity Flink ships, so code that assumed a bigger tuple fails here first. The message is the invalid position.
Source
Thrown at flink-core-api/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java:137
switch (pos) {
case 0:
return (T) this.f0;
case 1:
return (T) this.f1;
case 2:
return (T) this.f2;
case 3:
return (T) this.f3;
case 4:
return (T) this.f4;
case 5:
return (T) this.f5;
case 6:
return (T) this.f6;
case 7:
return (T) this.f7;
default:
throw new IndexOutOfBoundsException(String.valueOf(pos));
}
}
@Override
@SuppressWarnings("unchecked")
public <T> void setField(T value, int pos) {
switch (pos) {
case 0:
this.f0 = (T0) value;
break;
case 1:
this.f1 = (T1) value;
break;
case 2:
this.f2 = (T2) value;
break;
case 3:
this.f3 = (T3) value;View on GitHub (pinned to 2f3c205e92)
Solutions
- Use positions 0..7 for Tuple8.getField
- If you need more than 8 fields, switch to Tuple9, a POJO, or a Row instead of indexing past the arity
- Bounds-check with tuple.getArity() before positional access
- Access typed fields (tuple.f0..tuple.f7) directly when the position is static
Example fix
// before Object v = tuple8.getField(8); // after Object v = (pos >= 0 && pos < tuple8.getArity()) ? tuple8.getField(pos) : null;
Defensive patterns
Strategy: validation
Validate before calling
if (pos < 0 || pos >= tuple8.getArity()) {
throw new IllegalArgumentException("pos " + pos + " outside Tuple8 arity 8");
}
Object v = tuple8.getField(pos); Try / catch
catch (IndexOutOfBoundsException e) { /* pos in message; rethrow with the projection/schema it came from */ } Prevention
- Positions 0..7 only; there is no field 8 on Tuple8
- If a schema needs more than 8 fields, switch to Tuple9/POJO/Row deliberately and update positional code
- Bounds-check indices from Table/SQL projections against the tuple arity
When it happens
Trigger: getField(8) or a negative index; widening a schema past eight fields but still using Tuple8 with unclamped positions; 1-based indices passed as 0-based.
Common situations: A record type grows to 9+ fields while positional access code still assumes 8 is valid; projection lists reused across tuple sizes; off-by-one iteration.
Related errors
- {pos}
- {pos}
- {pos}
- Tuple position is out of range: {f}
- Tuple size must be greater than 0. Size: {type.getArity()}
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/323bf11cd3c0e06e.
Report an issue: GitHub.