{"record":{"id":"83e5c4d067275b47","repo":"apache/flink","slug":"invalid-tuple-field-reference-83e5c4","errorCode":null,"errorMessage":"Invalid tuple field reference \"{}\".","messagePattern":"Invalid tuple field reference \"(.+?)\"\\.","errorType":"exception","errorClass":"InvalidFieldReferenceException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java","lineNumber":105,"sourceCode":"    }\n\n    /** Returns the field types. */\n    public TypeInformation<?>[] getFieldTypes() {\n        return types;\n    }\n\n    @Override\n    public int getTotalFields() {\n        return totalFields;\n    }\n\n    @Override\n    public void getFlatFields(\n            String fieldExpression, int offset, List<FlatFieldDescriptor> result) {\n\n        Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression);\n        if (!matcher.matches()) {\n            throw new InvalidFieldReferenceException(\n                    \"Invalid tuple field reference \\\"\" + fieldExpression + \"\\\".\");\n        }\n\n        String field = matcher.group(0);\n        if (field.equals(ExpressionKeys.SELECT_ALL_CHAR)\n                || field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {\n            // handle select all\n            int keyPosition = 0;\n            for (TypeInformation<?> type : types) {\n                if (type instanceof CompositeType) {\n                    CompositeType<?> cType = (CompositeType<?>) type;\n                    cType.getFlatFields(\n                            String.valueOf(ExpressionKeys.SELECT_ALL_CHAR),\n                            offset + keyPosition,\n                            result);\n                    keyPosition += cType.getTotalFields() - 1;\n                } else {\n                    result.add(new FlatFieldDescriptor(offset + keyPosition, type));","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java#L87-L123","documentation":"Thrown by TupleTypeInfoBase.getFlatFields when the fieldExpression does not match the tuple field regex. Tuple fields are addressed as 'f0', 'f1', ..., or bare integers '0', '1', ... (optionally dotted with a nested tail), or '*'/'_' wildcards. Any other syntax fails. This is an InvalidFieldReferenceException.","triggerScenarios":"Calling tupleType.getFlatFields(\"name\") (tuples use f0/f1 not arbitrary names), getFlatFields(\"f\"), getFlatFields(\"\"), or getFlatFields(\"f0.\"). Also reached via keyBy(\"myField\") on a Tuple-typed stream where the developer used POJO-style naming.","commonSituations":"Developer confuses Tuple field syntax (f0, f1) with POJO/Row field syntax (named fields). Common when switching from POJO to Tuple types without updating key expressions. Also triggered by passing empty strings or strings with invalid characters.","solutions":["Use tuple field syntax: 'f0', 'f1', ... or bare integers '0', '1', ....","For nested access use 'f0.subField' or '0.subField'.","Use '*' or '_' for all fields."],"exampleFix":"// before\ntupleStream.keyBy(\"myField\"); // Tuple2<String, Integer> has no 'myField'\n// after\ntupleStream.keyBy(\"f0\");","handlingStrategy":"validation","validationCode":"private static final Pattern TUPLE_FIELD =\n    Pattern.compile(\"(f?)([0-9]+)(\\\\\\.(.+))?\");\n\nvoid validateTupleFieldExpr(String expr) {\n    if (expr == null || !TUPLE_FIELD.matcher(expr).matches()) {\n        throw new IllegalArgumentException(\n            \"Invalid tuple field expression: \" + expr);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use tuple field syntax (f0, f1, ... or bare 0, 1, ...) — not named fields.","Remember Tuple fields are positional, not named like POJO/Row."],"tags":["tuple","field-reference","type-system","keyby","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}