apache/flink · error · InvalidFieldReferenceException
Invalid format of POJO field expression "{}".
Error message
Invalid format of POJO field expression "{}". What it means
Thrown by PojoTypeInfo.getTypeAt(String) when the fieldExpression does not match the POJO nested-field regex and is not a wildcard character. The expression is syntactically malformed for a POJO field reference. This is an InvalidFieldReferenceException.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java:251
+ 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;
}
}
if (fieldPos == -1) {
throw new InvalidFieldReferenceException(
"Unable to find field \"" + field + "\" in type " + this + ".");View on GitHub (pinned to 2f3c205e92)
Solutions
- Use a valid POJO field-name identifier (letter/underscore/'$' start, alphanumeric/underscore/'$' body).
- For nested access use dot-separated valid identifiers: "outerField.innerField".
Example fix
// before
pojoTypeInfo.getTypeAt("f0"); // f0 is tuple syntax, not POJO
// after
pojoTypeInfo.getTypeAt("fieldName"); Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern POJO_NESTED =
Pattern.compile("([\\p{L}_$][\\p{L}\\p{Digit}_$]*)(\\\.(.+))?");
void validateGetTypeAtExpr(String expr) {
if (!POJO_NESTED.matcher(expr).matches()) {
throw new IllegalArgumentException("Malformed field expression: " + expr);
}
} Prevention
- Validate field expressions against the POJO identifier regex before calling getTypeAt.
- Avoid passing tuple-style 'f0' expressions to POJO types.
When it happens
Trigger: Calling pojoTypeInfo.getTypeAt("123"), getTypeAt(""), getTypeAt("field-name"), or getTypeAt("a."). The PATTERN_NESTED_FIELDS matcher fails and the expression does not start with '*' or '_'.
Common situations: Direct programmatic use of getTypeAt with a non-identifier string, or passing a tuple-style key ('f0') to a POJO type's getTypeAt. Occasionally reached when ExpressionKeys strips a trailing wildcard and leaves an empty or malformed remainder.
Related errors
- Invalid POJO field reference "{}".
- Unable to find field "{}" in type {}.
- Wildcard expressions are not allowed here.
- Invalid format of Row field expression "{}".
- Nested field expression "{}" not possible on atomic type {}.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/57e64cf68f93e8c7.
Report an issue: GitHub.