apache/flink · error · InvalidFieldReferenceException
Wildcard expressions are not allowed here.
Error message
Wildcard expressions are not allowed here.
What it means
Thrown by TupleTypeInfoBase.getTypeAt(String) when a wildcard character ('*' or '_') is used as a field expression. Wildcards are only supported by getFlatFields, not by getTypeAt, which expects a concrete field position like 'f0' or '1'. The method validates the expression against PATTERN_NESTED_FIELDS ((f?)([0-9]+)) and explicitly rejects the SELECT_ALL_CHAR before falling through to the generic invalid-format error.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java:191
throw new InvalidFieldReferenceException(
"Nested field expression \""
+ tail
+ "\" 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 \""View on GitHub (pinned to 2f3c205e92)
Solutions
- Replace the wildcard with a concrete field index, e.g. getTypeAt("f0") or getTypeAt("0").
- If you need all fields, use getFlatFields(fieldExpression, offset, result) instead of getTypeAt.
- Review the calling code to ensure you are not forwarding a user-facing '*' selector into a type-resolution path.
Example fix
// before
tupleType.getTypeAt("*");
// after
tupleType.getTypeAt("f0"); Defensive patterns
Strategy: validation
Validate before calling
if ("*".equals(fieldExpr) || "_".equals(fieldExpr)) {
throw new IllegalArgumentException("Wildcard not supported by getTypeAt; use getFlatFields instead.");
}
tupleType.getTypeAt(fieldExpr); Type guard
static boolean isValidTupleFieldExpression(String expr) {
return expr != null && !"*".equals(expr) && !"_".equals(expr)
&& expr.matches("(f?)([0-9]+)(\\.(.+))?");
} Prevention
- Never pass wildcard characters to getTypeAt; it only accepts concrete field indices.
- Use getFlatFields if wildcard selection is needed.
- Validate field expressions against the regex (f?)([0-9]+) before calling getTypeAt.
When it happens
Trigger: Calling tupleType.getTypeAt("*") or tupleType.getTypeAt("_") on a TupleTypeInfoBase instance (e.g. TupleTypeInfo for Tuple2). Also triggered indirectly when a join/group/select key selector that uses wildcard notation is resolved through getTypeAt instead of getFlatFields.
Common situations: A developer confuses the field-selection API for keys (which supports '*' for 'all fields') with the type-lookup API. Happens when programmatically building dataflows and passing a wildcard key string where a specific tuple field index is required.
Related errors
- Invalid format of tuple field expression "{}".
- 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/a837d126b9be8d85.
Report an issue: GitHub.