apache/flink · error · IndexOutOfBoundsException
{pos}
Error message
{pos} What it means
Tuple7.getField(int pos) throws IndexOutOfBoundsException when the requested field position is outside 0..6. Tuples are fixed-arity, so any position greater than the last field (f6) or negative is invalid. The exception message is just the bad position value.
Source
Thrown at flink-core-api/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java:129
@SuppressWarnings("unchecked")
public <T> T getField(int pos) {
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;
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..6 for Tuple7.getField
- Bounds-check against tuple.getArity() before calling
- Validate externally supplied field indices once, at ingestion, with a clear error message
- Use tuple.f0..tuple.f6 directly when the field is known statically
Example fix
// before Object v = tuple7.getField(7); // after Object v = (pos >= 0 && pos < tuple7.getArity()) ? tuple7.getField(pos) : null;
Defensive patterns
Strategy: validation
Validate before calling
if (pos < 0 || pos >= tuple7.getArity()) {
throw new IllegalArgumentException("pos " + pos + " outside Tuple7 arity 7");
}
Object v = tuple7.getField(pos); Try / catch
catch (IndexOutOfBoundsException e) { /* log the index source (projection list, config) and rethrow */ } Prevention
- Use 0-based positions 0..6
- Convert 1-based external column numbers with pos - 1 and range-check
- Bound field loops by getArity(), never by a hardcoded constant from another tuple type
When it happens
Trigger: Calling getField(7) or a negative index on Tuple7; iterating field positions taken from a larger tuple's arity; translating 1-based external field numbers directly into this 0-based API.
Common situations: Schema evolution where a Tuple8 position list is applied to a Tuple7; positional access driven by SQL/Table projection indices that no longer match the tuple arity; loop bounds off by one (`i <= getArity()`).
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/370a9b4e07cb68f5.
Report an issue: GitHub.