{"record":{"id":"ee243c4663658b0d","repo":"flowable/flowable-engine","slug":"userid-and-groupid-cannot-both-be-null-ee243c","errorCode":null,"errorMessage":"userId and groupId cannot both be null","messagePattern":"userId and groupId cannot both be 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":58,"sourceCode":"    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);\n\n        return null;\n    }\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkForCaseDefinitionCmd.java#L40-L76","documentation":"When adding an identity link to a case definition, at least one of userId or groupId must be provided; both being null means there is no identity to link, so validateParams throws FlowableIllegalArgumentException.","triggerScenarios":"Calling cmmnRepositoryService.addIdentityLink(caseDefinitionId, null, null, type) — e.g. both user and group variables null after failed lookups, or a form where neither field was filled.","commonSituations":"Candidate-starter configuration screens submitting empty user+group, data-migration scripts with blank identity columns, or wrong variable wiring so both arguments bind to null.","solutions":["Provide either a userId or a groupId (and a matching identityIdType) for the link","Validate in the UI/service layer that at least one identity field is set before calling the API","If neither applies, skip creating the identity link entirely rather than calling with nulls"],"exampleFix":"// before\nrepositoryService.addIdentityLink(defId, userId, groupId, type); // both null\n// after\nif (userId == null && groupId == null) {\n    throw new IllegalArgumentException(\"userId or groupId must be provided\");\n}\nrepositoryService.addIdentityLink(defId, userId, groupId, type);","handlingStrategy":"validation","validationCode":"if (userId == null && groupId == null) throw new IllegalArgumentException(\"userId or groupId must be provided\");\nrepositoryService.addIdentityLink(defId, userId, groupId, type);","typeGuard":"boolean hasIdentityTarget(String userId, String groupId) { return userId != null || groupId != null; }","tryCatchPattern":"try {\n    repositoryService.addIdentityLink(defId, userId, groupId, type);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Identity link skipped: {}\", e.getMessage());\n}","preventionTips":["Require at least one identity field in forms/DTOs","Skip link creation when both are absent instead of calling with nulls","Validate at the service boundary"],"tags":["cmmn","identity-link","validation","missing-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-14T05:17:10.506Z"}