{"record":{"id":"5e611ce492f9d740","repo":"flowable/flowable-engine","slug":"the-case-instance-id-must-be-provided-when-creatin","errorCode":null,"errorMessage":"The case instance id must be provided when creating a new plan item instance","messagePattern":"The case instance 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":142,"sourceCode":"    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":124,"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#L124-L146","documentation":"Thrown by PlanItemInstanceEntityBuilderImpl.validateData when a plan item instance is created without a case instance id. The builder requires planItem, caseDefinitionId and caseInstanceId to all be set before constructing the entity. This is an internal invariant check protecting data integrity in the CMMN engine.","triggerScenarios":"Calling the PlanItemInstanceEntityBuilder's create() with a builder where caseInstanceId was never set, even though planItem and caseDefinitionId were provided.","commonSituations":"Custom engine code or command extensions that construct plan item instances programmatically; engine upgrades where builder fields were added; copy/paste of builder code omitting one fluent setter call.","solutions":["Ensure caseInstanceId is set on the PlanItemInstanceEntityBuilder before create()","Verify the parent CaseInstanceEntity was started and persisted (has a generated id) before creating plan item instances","Check that any custom command that builds plan item instances passes the case instance id through"],"exampleFix":"// before\nPlanItemInstanceEntityBuilderImpl builder = new PlanItemInstanceEntityBuilderImpl(commandContext)\n    .planItem(planItem)\n    .caseDefinitionId(caseDefinitionId);\n// after\nPlanItemInstanceEntityBuilderImpl builder = new PlanItemInstanceEntityBuilderImpl(commandContext)\n    .planItem(planItem)\n    .caseDefinitionId(caseDefinitionId)\n    .caseInstanceId(caseInstance.getId());","handlingStrategy":"validation","validationCode":"if (planItem == null || caseDefinitionId == null || caseInstanceId == null) {\n    throw new IllegalArgumentException(\"planItem, caseDefinitionId and caseInstanceId are all required\");\n}","typeGuard":"boolean canBuild = planItem != null && caseDefinitionId != null && caseInstanceId != null;","tryCatchPattern":"try {\n    builder.create();\n} catch (FlowableIllegalArgumentException e) {\n    // inspect builder state, re-run with caseInstanceId set\n}","preventionTips":["Always set all required builder fields in one fluent chain","Write a small factory method that sets all mandatory fields","Assert the case instance id exists before building plan item instances"],"tags":["cmmn","validation","null-argument"],"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"}