apache/flink · error · InvalidFieldReferenceException
Invalid format of tuple field expression "{}".
Error message
Invalid format of tuple field expression "{}". What it means
Thrown by TupleTypeInfoBase.getTypeAt(String) when the field expression does not match PATTERN_NESTED_FIELDS. The expected format is an integer with optional 'f' prefix (e.g. '0', 'f0', 'f2'), optionally followed by a dot and a nested expression (e.g. 'f0.name'). Any string that deviates from this pattern (and is not a wildcard) triggers this error.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java:194
+ "\" not possible on atomic type "
+ fieldType
+ ".");
}
}
}
}
@Override
public <X> TypeInformation<X> getTypeAt(String fieldExpression) {
Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);
if (!matcher.matches()) {
if (fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR)
|| fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
throw new InvalidFieldReferenceException(
"Wildcard expressions are not allowed here.");
} else {
throw new InvalidFieldReferenceException(
"Invalid format of tuple field expression \"" + fieldExpression + "\".");
}
}
String fieldStr = matcher.group(1);
Matcher fieldMatcher = PATTERN_FIELD.matcher(fieldStr);
if (!fieldMatcher.matches()) {
throw new RuntimeException("Invalid matcher pattern");
}
String field = fieldMatcher.group(2);
int fieldPos = Integer.valueOf(field);
if (fieldPos >= this.getArity()) {
throw new InvalidFieldReferenceException(
"Tuple field expression \""
+ fieldStr
+ "\" out of bounds of "
+ this.toString()View on GitHub (pinned to 2f3c205e92)
Solutions
- Use a numeric field expression: 'f0', 'f1', ..., 'f{arity-1}' or plain '0', '1', ...
- If the type is actually a POJO, use PojoTypeInfo.getTypeAt(String) which accepts field names.
- If the type is a Row, use RowTypeInfo.getTypeAt(String) which accepts both field names and indices.
- Double-check the TypeInformation subtype at runtime before calling getTypeAt.
Example fix
// before
tupleType.getTypeAt("myField");
// after
tupleType.getTypeAt("f0"); Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern TUPLE_FIELD = Pattern.compile("(f?)([0-9]+)(\\.(.+))?");
if (!TUPLE_FIELD.matcher(fieldExpr).matches()) {
throw new IllegalArgumentException("Invalid tuple field expression: " + fieldExpr);
}
tupleType.getTypeAt(fieldExpr); Type guard
static boolean isValidTupleFieldExpression(String expr) {
return expr != null && expr.matches("(f?)([0-9]+)(\\.(.+))?");
} Prevention
- Validate field expressions with the tuple regex before calling getTypeAt.
- Use integer-based getTypeAt(int pos) when the field index is known numerically.
- Remember Tuple fields are accessed by index (f0, f1, ...), not by name.
When it happens
Trigger: Calling tupleType.getTypeAt("name") on a TupleTypeInfoBase (use PojoTypeInfo for named fields). Calling getTypeAt("field1"). Calling getTypeAt("f0.f1.f2") when a nested field is not a CompositeType.
Common situations: Developer treats a Tuple as a POJO and tries to access fields by name. Confusion between Tuple field selectors (integer indices) and POJO field selectors (string names). Passing a Row field name to a Tuple type. Off-by-one or typo in the field expression string.
Related errors
- Wildcard expressions are not allowed here.
- Usage of class Tuple as a type is not allowed. Use a concret
- Tuple needs to be parameterized by using generics.
- Type information extraction for tuples (except Tuple0) canno
- Automatic type extraction is not possible on candidates with
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/72a3f9e9bfb5b6ed.
Report an issue: GitHub.