{"record":{"id":"3dd4dd34da9939bf","repo":"apache/flink","slug":"could-not-determine-typeinformation-for-the-output","errorCode":null,"errorMessage":"Could not determine TypeInformation for the OutputTag type. The most common reason is forgetting to make the OutputTag an anonymous inner class. It is also not possible to use generic type variables with OutputTags, such as 'Tuple2<A, B>'.","messagePattern":"Could not determine TypeInformation for the OutputTag type\\. The most common reason is forgetting to make the OutputTag an anonymous inner class\\. It is also not possible to use generic type variables with OutputTags, such as 'Tuple2<A, B>'\\.","errorType":"validation","errorClass":"InvalidTypesException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/OutputTag.java","lineNumber":68,"sourceCode":"\n    private final String id;\n\n    private final TypeInformation<T> typeInfo;\n\n    /**\n     * Creates a new named {@code OutputTag} with the given id.\n     *\n     * @param id The id of the created {@code OutputTag}.\n     */\n    public OutputTag(String id) {\n        Preconditions.checkNotNull(id, \"OutputTag id cannot be null.\");\n        Preconditions.checkArgument(!id.isEmpty(), \"OutputTag id must not be empty.\");\n        this.id = id;\n\n        try {\n            this.typeInfo = TypeExtractor.createTypeInfo(this, OutputTag.class, getClass(), 0);\n        } catch (InvalidTypesException e) {\n            throw new InvalidTypesException(\n                    \"Could not determine TypeInformation for the OutputTag type. \"\n                            + \"The most common reason is forgetting to make the OutputTag an anonymous inner class. \"\n                            + \"It is also not possible to use generic type variables with OutputTags, such as 'Tuple2<A, B>'.\",\n                    e);\n        }\n    }\n\n    /**\n     * Creates a new named {@code OutputTag} with the given id and output {@link TypeInformation}.\n     *\n     * @param id The id of the created {@code OutputTag}.\n     * @param typeInfo The {@code TypeInformation} for the side output.\n     */\n    public OutputTag(String id, TypeInformation<T> typeInfo) {\n        Preconditions.checkNotNull(id, \"OutputTag id cannot be null.\");\n        Preconditions.checkArgument(!id.isEmpty(), \"OutputTag id must not be empty.\");\n        this.id = id;\n        this.typeInfo = Preconditions.checkNotNull(typeInfo, \"TypeInformation cannot be null.\");","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/OutputTag.java#L50-L86","documentation":"OutputTag's no-TypeInformation constructor extracts the side-output type via TypeExtractor at construction time; when extraction fails (InvalidTypesException), it rethrows with this explanatory InvalidTypesException. Type extraction only works for concrete, fully-resolvable generic types — the canonical pattern is an anonymous subclass that fixes the type parameter, e.g. new OutputTag<Tuple2<String, Long>>(\"id\"){}. The message names the two usual causes: non-anonymous usage and generic type variables.","triggerScenarios":"new OutputTag<Tuple2<String, Long>>(\"id\") without the trailing {}; using OutputTag<T> inside a generic function/method where T is erased; serializing an OutputTag subclass with a wildcard or type-variable parameter.","commonSituations":"Side outputs in process function code first written without '{}'; reusable OutputTags in generic base classes; Kotlin/Scala code dropping the anonymous-subclass trick (Kotlin: object : OutputTag<Tuple2<String, Long>>(\"id\") {}).","solutions":["Make the OutputTag an anonymous inner class: add '{}' — new OutputTag<Tuple2<String, Long>>(\"side\"){}.","Or pass TypeInformation explicitly: new OutputTag<>(\"side\", Types.TUPLE(Types.STRING, Types.LONG)).","Never declare OutputTag fields with an unbound generic variable; instantiate at a concrete type.","In Kotlin use 'object : OutputTag<...>(\"id\") {}'."],"exampleFix":"// before\nOutputTag<Tuple2<String, Long>> tag = new OutputTag<Tuple2<String, Long>>(\"side\"); // no {}\n\n// after\nOutputTag<Tuple2<String, Long>> tag = new OutputTag<Tuple2<String, Long>>(\"side\") {};\n// or explicit:\nOutputTag<Tuple2<String, Long>> tag2 = new OutputTag<>(\"side\", Types.TUPLE(Types.STRING, Types.LONG));","handlingStrategy":"type-guard","validationCode":"static <T> OutputTag<T> outputTag(String id, TypeInformation<T> ti) {\n    return new OutputTag<>(id, ti); // explicit TypeInformation never fails extraction\n}","typeGuard":"// compile-time-safe pattern: anonymous subclass fixes the type parameter\nnew OutputTag<Tuple2<String, Long>>(\"side\") {}","tryCatchPattern":"try { new OutputTag<...>(id); } catch (InvalidTypesException e) { /* fall back to explicit TypeInformation overload */ } — better: always use the (id, TypeInformation) constructor in shared/generic code.","preventionTips":["Always append '{}' to OutputTag constructors.","In generic classes, require TypeInformation as a constructor parameter and use the 2-arg OutputTag.","Kotlin: object : OutputTag<...>(\"id\") {}."],"tags":["side-outputs","type-information","generics","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}