{"record":{"id":"6133b74280a7d828","repo":"flowable/flowable-engine","slug":"scopecontainer-cannot-be-null","errorCode":null,"errorMessage":"scopeContainer cannot be null","messagePattern":"scopeContainer cannot be null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/scripting/CmmnVariableScopeResolver.java","lineNumber":68,"sourceCode":"            \"cmmnManagementService\", CmmnEngineConfiguration::getCmmnManagementService,\n            \"taskService\", CmmnEngineConfiguration::getCmmnTaskService,\n            \"cmmnTaskService\", CmmnEngineConfiguration::getCmmnTaskService\n    );\n\n    protected static final Set<String> KEYS = Set.of(\n        CASE_INSTANCE_KEY,\n        PLAN_ITEM_INSTANCE_KEY,\n        TASK_KEY\n    );\n\n    protected CmmnEngineConfiguration engineConfiguration;\n    protected VariableContainer scopeContainer;\n    protected VariableContainer inputVariableContainer;\n\n    public CmmnVariableScopeResolver(CmmnEngineConfiguration engineConfiguration, VariableContainer scopeContainer,\n            VariableContainer inputVariableContainer) {\n        if (scopeContainer == null) {\n            throw new FlowableIllegalArgumentException(\"scopeContainer cannot be null\");\n        }\n        this.scopeContainer = scopeContainer;\n        this.inputVariableContainer = inputVariableContainer;\n        this.engineConfiguration = engineConfiguration;\n    }\n\n    @Override\n    public boolean containsKey(Object key) {\n        return inputVariableContainer.hasVariable((String) key) || KEYS.contains(key)\n                || SERVICE_RESOLVERS.containsKey(key) && engineConfiguration.isServicesEnabledInScripting();\n    }\n\n    @Override\n    public Object get(Object key) {\n        if (SERVICE_RESOLVERS.containsKey((String) key)) {\n            if (engineConfiguration.isServicesEnabledInScripting()) {\n                return SERVICE_RESOLVERS.get(key).apply(engineConfiguration);\n            } else {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/scripting/CmmnVariableScopeResolver.java#L50-L86","documentation":"The CmmnVariableScopeResolver constructor throws FlowableIllegalArgumentException when scopeContainer is null. The resolver evaluates expressions against a scope (plan item instance or case instance); without a scope container there is nothing to resolve variables against, so construction fails fast.","triggerScenarios":"Constructing CmmnVariableScopeResolver(engineConfiguration, null, inputVariableContainer) — usually when the calling delegate passes a null PlanItemInstanceEntity or CaseInstanceEntity into expression/script evaluation.","commonSituations":"Custom delegates or listeners evaluating expressions with a manually built scope that was never resolved; standalone scripting of CMMN expressions outside a running case; NPE-fix refactors that pass null through.","solutions":["Ensure the scope container (plan item instance or case instance entity) is loaded before building the resolver.","Pass the correct VariableContainer: use the plan item instance from the delegate context, not a null.","If evaluating outside a case, use a different resolver/VariableScope rather than CmmnVariableScopeResolver with null."],"exampleFix":"// before\nnew CmmnVariableScopeResolver(config, null, inputContainer);\n// after\nVariableContainer scope = planItemInstance != null ? planItemInstance : caseInstance;\nnew CmmnVariableScopeResolver(config, scope, inputContainer);","handlingStrategy":"type-guard","validationCode":"if (scopeContainer == null) throw new IllegalStateException(\"Cannot resolve CMMN variables without a scope container\");","typeGuard":"VariableContainer resolveScope(PlanItemInstance p, CaseInstance c) {\n    if (p != null) return p;\n    if (c != null) return c;\n    throw new IllegalStateException(\"No VariableContainer available\");\n}","tryCatchPattern":"try { new CmmnVariableScopeResolver(config, scope, input); } catch (FlowableIllegalArgumentException e) { throw new IllegalStateException(\"scopeContainer missing for expression evaluation\", e); }","preventionTips":["Always obtain the scope from the active delegate (DelegatePlanItemInstance/CaseInstance) rather than passing null.","Do not instantiate the resolver outside a running case context."],"tags":["flowable","cmmn","scripting","expression","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}