{"record":{"id":"ea78ad564cfa1af6","repo":"flowable/flowable-engine","slug":"casedefinitionid-is-null","errorCode":null,"errorMessage":"caseDefinitionId is null","messagePattern":"caseDefinitionId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkForCaseDefinitionCmd.java","lineNumber":54,"sourceCode":"    protected String caseDefinitionId;\n\n    protected String userId;\n\n    protected String groupId;\n\n    public AddIdentityLinkForCaseDefinitionCmd(String caseDefinitionId, String userId, String groupId,\n            CmmnEngineConfiguration cmmnEngineConfiguration) {\n        \n        validateParams(userId, groupId, caseDefinitionId);\n        this.caseDefinitionId = caseDefinitionId;\n        this.userId = userId;\n        this.groupId = groupId;\n        this.cmmnEngineConfiguration = cmmnEngineConfiguration;\n    }\n\n    protected void validateParams(String userId, String groupId, String caseDefinitionId) {\n        if (caseDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"caseDefinitionId is null\");\n        }\n\n        if (userId == null && groupId == null) {\n            throw new FlowableIllegalArgumentException(\"userId and groupId cannot both be null\");\n        }\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CaseDefinitionEntity caseDefinition = cmmnEngineConfiguration.getCaseDefinitionEntityManager().findById(caseDefinitionId);\n\n        if (caseDefinition == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find case definition with id \" + caseDefinitionId, CaseDefinition.class);\n        }\n\n        IdentityLinkEntity identityLinkEntity = cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getIdentityLinkService()\n                .createScopeDefinitionIdentityLink(caseDefinition.getId(), ScopeTypes.CMMN, userId, groupId);\n        caseDefinition.getIdentityLinks().add(identityLinkEntity);","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkForCaseDefinitionCmd.java#L36-L72","documentation":"AddIdentityLinkForCaseDefinitionCmd attaches identity links (candidate starter users/groups) to a case definition, and validateParams requires a non-null caseDefinitionId. Without it there is no definition to attach to, so FlowableIllegalArgumentException is thrown.","triggerScenarios":"Calling cmmnRepositoryService.addIdentityLink(caseDefinitionId, userId, groupId, type) with a null caseDefinitionId, e.g. when the id came from a failed deployment lookup or an unset request parameter.","commonSituations":"Case definition lookup by key returning null and the null being passed on, REST payloads missing the definition id, or code assuming a default definition exists.","solutions":["Obtain the id via cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).latestVersion().singleResult() and null-check it before linking","Validate inputs at the caller and return a 4xx-style message when the definition id is absent","Pass the latest deployed definition id explicitly after deployment"],"exampleFix":"// before\nrepositoryService.addIdentityLink(caseDefinitionId, userId, null, IdentityLinkType.CANDIDATE_STARTER);\n// after\nif (caseDefinitionId == null) throw new IllegalArgumentException(\"caseDefinitionId is required\");\nrepositoryService.addIdentityLink(caseDefinitionId, userId, null, IdentityLinkType.CANDIDATE_STARTER);","handlingStrategy":"validation","validationCode":"if (caseDefinitionId == null) throw new IllegalArgumentException(\"caseDefinitionId is required\");\nrepositoryService.addIdentityLink(caseDefinitionId, userId, groupId, type);","typeGuard":"boolean hasDefinitionId(String id) { return id != null && !id.isBlank(); }","tryCatchPattern":"try {\n    repositoryService.addIdentityLink(defId, userId, groupId, type);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"caseDefinitionId missing: \" + e.getMessage());\n}","preventionTips":["Resolve the id from a CaseDefinitionQuery before linking","Null-check ids arriving from REST/DTO layers","Never pass ids captured before a redeploy without re-validating"],"tags":["cmmn","identity-link","null-check","case-definition"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}