{"record":{"id":"653c5a38051cab37","repo":"apache/flink","slug":"execution-config-has-not-been-set-properly-for-thi","errorCode":null,"errorMessage":"Execution config has not been set properly for this plan","messagePattern":"Execution config has not been set properly for this plan","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/Plan.java","lineNumber":303,"sourceCode":"\n    /**\n     * Gets the optimizer post-pass class for this job. The post-pass typically creates utility\n     * classes for data types and is specific to a particular data model (record, tuple, Scala, ...)\n     *\n     * @return The name of the class implementing the optimizer post-pass.\n     */\n    public String getPostPassClassName() {\n        return \"org.apache.flink.optimizer.postpass.JavaApiPostPass\";\n    }\n\n    /**\n     * Gets the execution config object.\n     *\n     * @return The execution config object.\n     */\n    public ExecutionConfig getExecutionConfig() {\n        if (executionConfig == null) {\n            throw new RuntimeException(\"Execution config has not been set properly for this plan\");\n        }\n        return executionConfig;\n    }\n\n    /**\n     * Sets the runtime config object defining execution parameters.\n     *\n     * @param executionConfig The execution config to use.\n     */\n    public void setExecutionConfig(ExecutionConfig executionConfig) {\n        this.executionConfig = executionConfig;\n    }\n\n    // ------------------------------------------------------------------------\n\n    /**\n     * Traverses the job depth first from all data sinks on towards the sources.\n     *","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/Plan.java#L285-L321","documentation":"Thrown by Plan.getExecutionConfig() when the executionConfig field is null. A Plan is the data-flow description submitted to the optimizer; it must have its ExecutionConfig attached during program assembly (typically by the ExecutionEnvironment). If getExecutionConfig() is reached before the environment wired it in, the plan is incomplete and execution would otherwise NPE deeper in the optimizer.","triggerScenarios":"Calling plan.getExecutionConfig() on a Plan constructed directly (new Plan(...)) without invoking setExecutionConfig(...); deserializing a Plan from a serialized program where the config wasn't serialized; optimizer tests that build a Plan by hand.","commonSituations":"Unit tests constructing a Plan without an environment; custom client code that loads a saved plan; edge cases in the optimizer pipeline where the plan reaches post-pass before config attachment.","solutions":["Always set the ExecutionConfig on a manually constructed Plan: plan.setExecutionConfig(new ExecutionConfig()).","Use ExecutionEnvironment.getPlan() / createProgramPlan() helpers which attach the config automatically.","If loading a plan from a jar, ensure the entry-point environment initialized the config before plan extraction."],"exampleFix":"// before\nPlan plan = new Plan(operator, \"job\");\nplan.getExecutionConfig();\n// after\nPlan plan = new Plan(operator, \"job\");\nplan.setExecutionConfig(new ExecutionConfig());\nplan.getExecutionConfig();","handlingStrategy":"validation","validationCode":"if (plan.getExecutionConfig() == null) { // guard against the throw\n    plan.setExecutionConfig(new ExecutionConfig());\n}\n// safer: always set explicitly\nplan.setExecutionConfig(new ExecutionConfig());","typeGuard":null,"tryCatchPattern":"try { plan.getExecutionConfig(); }\ncatch (RuntimeException e) { plan.setExecutionConfig(new ExecutionConfig()); }","preventionTips":["Always call setExecutionConfig on manually built Plans.","Prefer ExecutionEnvironment helpers that attach the config automatically.","In tests, build Plans through an ExecutionEnvironment."],"tags":["plan","execution-config","optimizer","null-check"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}