apache/flink · error · InvalidFieldReferenceException
Wildcard expressions are not allowed here.
Error message
Wildcard expressions are not allowed here.
What it means
Thrown by PojoTypeInfo.getTypeAt(String) when the fieldExpression is a wildcard character ('*' or '_'). getTypeAt returns the TypeInformation of exactly one field, so a wildcard that selects all fields is semantically invalid here. This is an InvalidFieldReferenceException.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java:248
"Nested field expression \""
+ tail
+ "\" not possible on atomic type "
+ fieldType
+ ".");
}
}
}
@SuppressWarnings("unchecked")
@Override
@PublicEvolving
public <X> TypeInformation<X> getTypeAt(String fieldExpression) {
Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);
if (!matcher.matches()) {
if (fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR)
|| fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
throw new InvalidFieldReferenceException(
"Wildcard expressions are not allowed here.");
} else {
throw new InvalidFieldReferenceException(
"Invalid format of POJO field expression \"" + fieldExpression + "\".");
}
}
String field = matcher.group(1);
// get field
int fieldPos = -1;
TypeInformation<?> fieldType = null;
for (int i = 0; i < fields.length; i++) {
if (fields[i].getField().getName().equals(field)) {
fieldPos = i;
fieldType = fields[i].getTypeInformation();
break;
}
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Do not pass '*' or '_' to getTypeAt — use getFlatFields instead if you need all fields.
- If calling getTypeAt programmatically, filter out wildcard expressions before the call.
Example fix
// before
pojoTypeInfo.getTypeAt("*");
// after
pojoTypeInfo.getFlatFields("*"); Defensive patterns
Strategy: validation
Validate before calling
void safeGetTypeAt(CompositeType<?> type, String expr) {
if ("*".equals(expr) || "_".equals(expr)) {
throw new IllegalArgumentException(
"Use getFlatFields for wildcard expressions, not getTypeAt");
}
type.getTypeAt(expr);
} Prevention
- Never pass '*' or '_' to getTypeAt.
- Route wildcard expressions to getFlatFields only.
When it happens
Trigger: Calling pojoTypeInfo.getTypeAt("*") or pojoTypeInfo.getTypeAt("_"). ExpressionKeys calls getTypeAt internally at Keys.java:338 only after stripping wildcards, so end users rarely hit this directly — it indicates direct API misuse or a custom wrapper that forwards wildcard expressions.
Common situations: Programmatic code that passes the same expression list to both getFlatFields (which accepts '*') and getTypeAt (which does not). Rarely seen in typical DataStream/DataSet programs.
Related errors
- Invalid format of POJO field expression "{}".
- Wildcard expressions are not allowed here.
- Invalid POJO field reference "{}".
- Unable to find field "{}" in type {}.
- Nested field expression "{}" not possible on atomic type {}.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/e8a51290d80a9f27.
Report an issue: GitHub.