{"record":{"id":"e131ffb549158582","repo":"apache/flink","slug":"the-key-is-only-defined-for-keyed-operator-e131ff","errorCode":null,"errorMessage":"The key is only defined for keyed operator","messagePattern":"The key is only defined for keyed operator","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink-datastream/src/main/java/org/apache/flink/datastream/impl/operators/TwoOutputProcessOperator.java","lineNumber":182,"sourceCode":"            }\n        }\n    }\n\n    @Override\n    public void endInput() throws Exception {\n        userFunction.endInput(nonPartitionedContext);\n    }\n\n    protected TimestampCollector<OUT_MAIN> getMainCollector() {\n        return new OutputCollector<>(output);\n    }\n\n    public TimestampCollector<OUT_SIDE> getSideCollector() {\n        return new SideOutputCollector(output);\n    }\n\n    protected Object currentKey() {\n        throw new UnsupportedOperationException(\"The key is only defined for keyed operator\");\n    }\n\n    protected BiConsumer<Runnable, Object> getProcessorWithKey() {\n        if (isAsyncKeyOrderedProcessingEnabled()) {\n            return (r, k) -> asyncProcessWithKey(k, r::run);\n        } else {\n            return (r, k) -> {\n                Object oldKey = currentKey();\n                try {\n                    r.run();\n                } finally {\n                    setCurrentKey(oldKey);\n                }\n            };\n        }\n    }\n\n    protected TwoOutputNonPartitionedContext<OUT_MAIN, OUT_SIDE> getNonPartitionedContext() {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-datastream/src/main/java/org/apache/flink/datastream/impl/operators/TwoOutputProcessOperator.java#L164-L200","documentation":"Error \"The key is only defined for keyed operator\" thrown in apache/flink.","triggerScenarios":"Triggered at runtime when the operation fails because: The key is only defined for keyed operator.","commonSituations":"Commonly caused by misconfiguration, missing dependencies or files, unsupported types or operations, or invalid user input leading to: The key is only defined for keyed operator.","solutions":["Address the cause reported by the error message: The key is only defined for keyed operator","Verify the inputs, configuration values, and classpath/dependency setup related to this operation, then retry."],"exampleFix":"Correct the condition described (\"The key is only defined for keyed operator\") and rerun the job or command.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}