apache/flink · error · InvalidFieldReferenceException

Invalid format of Row field expression "{}".

Error message

Invalid format of Row field expression "{}".

What it means

Thrown by RowTypeInfo.getTypeAt(String) when the fieldExpression does not match the Row nested-field regex (integer or string identifier, optionally dotted) and is not a wildcard. The expression is syntactically malformed. This is an InvalidFieldReferenceException.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/RowTypeInfo.java:179

                                    + 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 Row field expression \"" + fieldExpression + "\".");
            }
        }

        String field = matcher.group(1);

        Matcher intFieldMatcher = PATTERN_INT_FIELD.matcher(field);
        int fieldIndex;
        if (intFieldMatcher.matches()) {
            // field expression is an integer
            fieldIndex = Integer.valueOf(field);
        } else {
            fieldIndex = this.getFieldIndex(field);
        }
        // fetch the field type will throw exception if the index is illegal
        TypeInformation<X> fieldType = this.getTypeAt(fieldIndex);

        String tail = matcher.group(3);

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Use a valid Row field expression: integer index, field name (f0 or custom), or dotted nested path.
  2. Avoid empty strings, trailing dots, hyphens, and spaces.

Example fix

// before
rowType.getTypeAt("field-name");
// after
rowType.getTypeAt("fieldName");
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern ROW_NESTED =
    Pattern.compile("([0-9]+|[\\p{L}_$][\\p{L}\\p{Digit}_$]*)(\\\.(.+))?");

void validateGetTypeAtExpr(String expr) {
    if (!ROW_NESTED.matcher(expr).matches()) {
        throw new IllegalArgumentException("Malformed: " + expr);
    }
}

Prevention

When it happens

Trigger: Calling rowType.getTypeAt(""), getTypeAt("field-name"), getTypeAt("f0."), or getTypeAt("a b"). The PATTERN_NESTED_FIELDS matcher fails and the expression is not exactly '*' or '_'.

Common situations: Passing a malformed string to getTypeAt programmatically, or using POJO-style or tuple-style syntax that doesn't match Row's combined integer+string pattern. Also reached when ExpressionKeys strips a wildcard and leaves an empty remainder.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/9ab8ee474d8487ac. Report an issue: GitHub.