apache/beam · error · java.lang.IllegalArgumentException
No field at index
Error message
No field at index <fieldIdx>
What it means
RowWithStorage backs a Row with a simple list of values; getValue(fieldIdx) throws IllegalArgumentException when the requested index is beyond the stored list size. The row's storage contains fewer values than the index asked for, i.e. caller and row disagree on the schema's field count.
Solutions
- Verify row.getSchema().getFieldCount() before indexing; iterate with row.getValues() or FieldAccessors
- Rebuild the row supplying values for every schema field
- If reading old data after a schema change, migrate rows or make the read tolerant of missing trailing fields
Example fix
// before for (int i = 0; i <= schema.getFieldCount(); i++) row.getValue(i); // after for (int i = 0; i < schema.getFieldCount(); i++) row.getValue(i);
Defensive patterns
Strategy: type-guard
Validate before calling
if (fieldIdx >= row.getSchema().getFieldCount()) throw new IllegalArgumentException("index " + fieldIdx + " out of range"); Type guard
boolean hasField(Row row, int idx) { return row.getValues().size() > idx; } Try / catch
try { return row.getValue(idx); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("No field at index")) return null; throw e; } Prevention
- Iterate using row.getValues() or FieldAccessors rather than raw indices
- Migrate stored rows after adding schema fields
- Validate value count equals schema field count at row construction
When it happens
Trigger: Calling row.getValue(i) where i >= values.size() — e.g. a Row built with Row.withSchema(...).addValues(...) given fewer values than the schema declares, or code iterating past the schema's field count on a truncated row.
Common situations: Schema changed (field added) but old serialized/stored rows have fewer values; addValues called with a short varargs list; off-by-one loops over row fields.
Related errors
- Cannot provide a coder for a Beam Row. Please provide a…
- Not a primitive type for field name
- Null value set on non-nullable field
- Position was out of bounds for ranges .
- Row expected fields ( ). initialized with <values.size>…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/d3d95cfc4e26fb16.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowWithStorage.java:39
import org.apache.beam.sdk.schemas.Schema;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Concrete subclass of {@link Row} that explicitly stores all fields of the row. */
public class RowWithStorage extends Row {
private final List<@Nullable Object> values;
RowWithStorage(Schema schema, List<@Nullable Object> values) {
super(schema);
this.values = values;
}
@Override
@SuppressWarnings("TypeParameterUnusedInFormals")
public <T extends @Nullable Object> T getValue(int fieldIdx) {
if (values.size() > fieldIdx) {
return (T) values.get(fieldIdx);
} else {
throw new IllegalArgumentException("No field at index " + fieldIdx);
}
}
@Override
public List<@Nullable Object> getValues() {
return values;
}
@Override
public int getFieldCount() {
return values.size();
}
}
View on GitHub (pinned to 12126d8942)