{"record":{"id":"0faa8050fe9b6852","repo":"flowable/flowable-engine","slug":"the-case-definition-id-must-be-provided-when-creat","errorCode":null,"errorMessage":"The case definition id must be provided when creating a new plan item instance","messagePattern":"The case definition id must be provided when creating a new plan item instance","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/persistence/entity/PlanItemInstanceEntityBuilderImpl.java","lineNumber":139,"sourceCode":"    public Map<String, Object> getLocalVariables() {\n        return localVariables;\n    }\n    public boolean hasLocalVariables() {\n        return localVariables != null && localVariables.size() > 0;\n    }\n    public boolean isAddToParent() {\n        return addToParent;\n    }\n    public boolean isSilentNameExpressionEvaluation() {\n        return silentNameExpressionEvaluation;\n    }\n\n    protected void validateData() {\n        if (planItem == null) {\n            throw new FlowableIllegalArgumentException(\"The plan item must be provided when creating a new plan item instance\");\n        }\n        if (caseDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"The case definition id must be provided when creating a new plan item instance\");\n        }\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"The case instance id must be provided when creating a new plan item instance\");\n        }\n    }\n}\n","sourceCodeStart":121,"sourceCodeEnd":146,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/persistence/entity/PlanItemInstanceEntityBuilderImpl.java#L121-L146","documentation":"During PlanItemInstanceEntityBuilderImpl.validateData(), the caseDefinitionId field must be non-null; a plan item instance is always tied to a case definition, so create() throws this FlowableIllegalArgumentException when it is missing. Sibling checks cover planItem and caseInstanceId.","triggerScenarios":"Calling create() on a plan item instance builder without setting caseDefinitionId(...) (even if planItem and caseInstanceId are provided).","commonSituations":"Custom engine extensions or tests building plan item instances where only the case instance id was known; builder configuration taken from an incomplete snippet.","solutions":["Set caseDefinitionId on the builder before create().","Fetch the definition id from the case instance (caseInstance.getCaseDefinitionId()) and pass it in.","Add a null check/precondition in custom code that assembles the builder."],"exampleFix":"// before\nbuilder.planItem(planItem).caseInstanceId(caseInstanceId).create();\n// after\nbuilder.planItem(planItem)\n    .caseDefinitionId(caseInstance.getCaseDefinitionId())\n    .caseInstanceId(caseInstanceId).create();","handlingStrategy":"validation","validationCode":"if (caseDefinitionId == null) throw new IllegalArgumentException(\"caseDefinitionId is required before create()\");","typeGuard":"boolean ready = planItem != null && caseDefinitionId != null && caseInstanceId != null;","tryCatchPattern":"try { entity = builder.create(); } catch (FlowableIllegalArgumentException e) { if (e.getMessage().contains(\"case definition id must be provided\")) { /* set caseDefinitionId(...) */ } throw e; }","preventionTips":["Pass caseInstance.getCaseDefinitionId() when the definition id isn't at hand.","Enforce all three required fields in a helper that finalizes the builder.","Add builder preconditions to integration tests.","Never create plan item instances outside a valid case definition context."],"tags":["cmmn","builder","validation","plan-item-instance"],"backgroundTag":"missing-required-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}