{"record":{"id":"90f4625d7ab2f7e9","repo":"apache/flink","slug":"the-broadcast-variable-with-name-name-has-not","errorCode":null,"errorMessage":"The broadcast variable with name '${name}' has not been set.","messagePattern":"The broadcast variable with name '(.+?)' has not been set\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/functions/util/RuntimeUDFContext.java","lineNumber":116,"sourceCode":"\n        // check if we have an initialized version\n        Object o = this.initializedBroadcastVars.get(name);\n        if (o != null) {\n            if (o instanceof List) {\n                return (List<RT>) o;\n            } else {\n                throw new IllegalStateException(\n                        \"The broadcast variable with name '\"\n                                + name\n                                + \"' is not a List. A different call must have requested this variable with a BroadcastVariableInitializer.\");\n            }\n        } else {\n            List<?> uninitialized = this.uninitializedBroadcastVars.remove(name);\n            if (uninitialized != null) {\n                this.initializedBroadcastVars.put(name, uninitialized);\n                return (List<RT>) uninitialized;\n            } else {\n                throw new IllegalArgumentException(\n                        \"The broadcast variable with name '\" + name + \"' has not been set.\");\n            }\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T, C> C getBroadcastVariableWithInitializer(\n            String name, BroadcastVariableInitializer<T, C> initializer) {\n\n        // check if we have an initialized version\n        Object o = this.initializedBroadcastVars.get(name);\n        if (o != null) {\n            return (C) o;\n        } else {\n            List<T> uninitialized = (List<T>) this.uninitializedBroadcastVars.remove(name);\n            if (uninitialized != null) {\n                C result = initializer.initializeBroadcastVariable(uninitialized);","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/functions/util/RuntimeUDFContext.java#L98-L134","documentation":"Thrown by RuntimeUDFContext.getBroadcastVariable() when no broadcast variable has been registered under the given name. The variable was not provided via withBroadcastSet() on the operator. The exception fires because neither the initialized nor uninitialized broadcast-variable maps contain the name.","triggerScenarios":"A RichFunction calls getRuntimeContext().getBroadcastVariable(name) but the upstream pipeline did not call .withBroadcastSet(dataSet, name) to register that broadcast set. The name does not match what was registered.","commonSituations":"Typo in the broadcast variable name string. Forgot to call withBroadcastSet(). The broadcast DataSet was filtered out or optimized away. Using broadcast variables in a streaming context where they are not supported without broadcast state patterns.","solutions":["Register the broadcast set on the operator: operator.withBroadcastSet(broadcastDataSet, name) using the exact same name string.","Double-check the name spelling and case in both the registration and the getBroadcastVariable() call.","Ensure the broadcast DataSet is non-empty and is actually part of the job graph."],"exampleFix":"// before\nDataSet<Integer> rules = env.fromElements(1, 2, 3);\ninput.map(new MyMapper()); // calls getBroadcastVariable(\"rules\") but not registered\n\n// after\ninput.map(new MyMapper()).withBroadcastSet(rules, \"rules\");","handlingStrategy":"validation","validationCode":"// Ensure withBroadcastSet() is called with the exact name\nDataSet<MyData> broadcastData = ...;\ninput.map(new MyMapper())\n     .withBroadcastSet(broadcastData, \"myRules\"); // must match getBroadcastVariable(\"myRules\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call withBroadcastSet(dataSet, name) for each broadcast variable the function accesses.","Use a constant or enum for broadcast variable names to avoid typos.","Verify the name string matches exactly (case-sensitive) in registration and access."],"tags":["broadcast-variable","runtime-context","missing-config","user-error"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}