{"record":{"id":"b99494d3bc3cdab9","repo":"flowable/flowable-engine","slug":"unsupported-variablecontainer-for-key-plan-item","errorCode":null,"errorMessage":"Unsupported variableContainer for key '${PLAN_ITEM_INSTANCE_KEY}': ${scopeContainer.class.name}","messagePattern":"Unsupported variableContainer for key '(.+?)': (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/scripting/CmmnVariableScopeResolver.java","lineNumber":118,"sourceCode":"                    return CommandContextUtil.getCaseInstanceEntityManager().findById(task.getScopeId());\n                }\n\n            }\n\n            throw new FlowableException(\"Unsupported variableContainer for key '\" + CASE_INSTANCE_KEY + \"': \" + scopeContainer.getClass().getName());\n\n        } else if (PLAN_ITEM_INSTANCE_KEY.equals(key)) {\n            if (scopeContainer instanceof PlanItemInstance) {\n                return scopeContainer;\n\n            }  else if (scopeContainer instanceof Task task) {\n                if (StringUtils.isNotEmpty(task.getSubScopeId()) && ScopeTypes.CMMN.equals(task.getScopeType())) {\n                    return CommandContextUtil.getPlanItemInstanceEntityManager().findById(task.getSubScopeId());\n                }\n\n            }\n\n            throw new FlowableException(\"Unsupported variableContainer for key '\" + PLAN_ITEM_INSTANCE_KEY + \"': \" + scopeContainer.getClass().getName());\n\n        } else if (TASK_KEY.equals(key)) {\n            if (scopeContainer instanceof Task) {\n                return scopeContainer;\n\n            } else  if (scopeContainer instanceof PlanItemInstance planItemInstance) {\n                return CommandContextUtil.getTaskService().findTasksBySubScopeIdScopeType(planItemInstance.getId(), ScopeTypes.CMMN);\n\n            } else {\n                throw new FlowableException(\"Unsupported variableContainer for key '\" + TASK_KEY + \"': \" + scopeContainer.getClass().getName());\n\n            }\n\n        } else {\n            return inputVariableContainer.getVariable((String) key);\n\n        }\n    }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/scripting/CmmnVariableScopeResolver.java#L100-L136","documentation":"Same resolver as error 930 but for PLAN_ITEM_INSTANCE_KEY: when the script requests the 'planItemInstance' variable and the scopeContainer is not a PlanItemInstance nor a Task with subScopeId scoped to a CMMN plan item, the resolver throws this FlowableException. It means the plan-item context required by the script is unavailable in the given container.","triggerScenarios":"Requesting 'planItemInstance' from a script whose variableContainer is a CaseInstanceEntity, a non-CMMN Task, or any other VariableScope type; calling resolver.get(PLAN_ITEM_INSTANCE_KEY, container) with a Task whose subScopeId is empty or whose scopeType is not CMMN.","commonSituations":"Scripts in case-level (not plan-item-level) listeners referencing planItemInstance; reusing a BPMN script context in CMMN; custom code resolving plan item variables from a case-wide scope.","solutions":["Only reference 'planItemInstance' in scripts/expressions evaluated at plan-item level (plan item listeners, plan-item-scoped tasks)","If the container is a Task, ensure getSubScopeId() is set and scopeType is CMMN so the resolver can look up the plan item","Resolve the PlanItemInstance explicitly via PlanItemInstanceEntityManager.findById(subScopeId) when working outside the resolver","Check the container type in the exception message and pass a PlanItemInstanceEntity instead"],"exampleFix":"// before\nObject pii = resolver.get(PLAN_ITEM_INSTANCE_KEY, caseInstanceEntity);\n// after\nObject pii = (container instanceof PlanItemInstance) ? resolver.get(PLAN_ITEM_INSTANCE_KEY, container) : planItemInstanceEntityManager.findById(task.getSubScopeId());","handlingStrategy":"type-guard","validationCode":"boolean canResolvePlanItem(Object container) {\n    return container instanceof PlanItemInstance\n        || (container instanceof org.flowable.task.api.Task t && t.getSubScopeId() != null && ScopeTypes.CMMN.equals(t.getScopeType()));\n}","typeGuard":"boolean isPlanItemScoped(Task t) { return t != null && StringUtils.isNotEmpty(t.getSubScopeId()) && ScopeTypes.CMMN.equals(t.getScopeType()); }","tryCatchPattern":"try { return resolver.get(PLAN_ITEM_INSTANCE_KEY, container); } catch (FlowableException e) { if (e.getMessage().startsWith(\"Unsupported variableContainer\")) return null; throw e; }","preventionTips":["Only use 'planItemInstance' in plan-item-level scripts/listeners","Never assume case-level scopes can resolve plan item variables","Reuse Flowable's VariableScopeResolverFactory instead of manual resolution"],"tags":["cmmn","scripting","variable-resolution","flowable"],"backgroundTag":"unsupported-operation","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"}