{"record":{"id":"d3d95cfc4e26fb16","repo":"apache/beam","slug":"no-field-at-index-fieldidx","errorCode":null,"errorMessage":"No field at index <fieldIdx>","messagePattern":"No field at index <fieldIdx>","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowWithStorage.java","lineNumber":39,"sourceCode":"import org.apache.beam.sdk.schemas.Schema;\nimport org.checkerframework.checker.nullness.qual.Nullable;\n\n/** Concrete subclass of {@link Row} that explicitly stores all fields of the row. */\npublic class RowWithStorage extends Row {\n  private final List<@Nullable Object> values;\n\n  RowWithStorage(Schema schema, List<@Nullable Object> values) {\n    super(schema);\n    this.values = values;\n  }\n\n  @Override\n  @SuppressWarnings(\"TypeParameterUnusedInFormals\")\n  public <T extends @Nullable Object> T getValue(int fieldIdx) {\n    if (values.size() > fieldIdx) {\n      return (T) values.get(fieldIdx);\n    } else {\n      throw new IllegalArgumentException(\"No field at index \" + fieldIdx);\n    }\n  }\n\n  @Override\n  public List<@Nullable Object> getValues() {\n    return values;\n  }\n\n  @Override\n  public int getFieldCount() {\n    return values.size();\n  }\n}\n","sourceCodeStart":21,"sourceCodeEnd":53,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowWithStorage.java#L21-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nfor (int i = 0; i <= schema.getFieldCount(); i++) row.getValue(i);\n// after\nfor (int i = 0; i < schema.getFieldCount(); i++) row.getValue(i);","handlingStrategy":"type-guard","validationCode":"if (fieldIdx >= row.getSchema().getFieldCount()) throw new IllegalArgumentException(\"index \" + fieldIdx + \" out of range\");","typeGuard":"boolean hasField(Row row, int idx) { return row.getValues().size() > idx; }","tryCatchPattern":"try { return row.getValue(idx); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"No field at index\")) return null; throw e; }","preventionTips":["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"],"tags":["java","apache-beam","row","index-out-of-bounds"],"backgroundTag":"index-out-of-bounds","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}