{"record":{"id":"45ea20366c69cdd1","repo":"flowable/flowable-engine","slug":"a-group-or-a-user-is-required-to-create-an-identit-45ea20","errorCode":null,"errorMessage":"A group or a user is required to create an identity link.","messagePattern":"A group or a user is required to create an identity link\\.","errorType":"http","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"warning","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskIdentityLinkCollectionResource.java","lineNumber":71,"sourceCode":"        }\n\n        return restResponseFactory.createRestIdentityLinks(taskService.getIdentityLinksForTask(task.getId()));\n    }\n\n    @ApiOperation(value = \"Create an identity link on a task\", tags = { \"Task Identity Links\" }, nickname = \"createTaskInstanceIdentityLinks\",\n            notes = \"It is possible to add either a user or a group.\", code = 201)\n    @ApiResponses(value = {\n            @ApiResponse(code = 201, message = \"Indicates the task was found and the identity link was created.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested task was not found or the task does not have the requested identityLink. The status contains additional information about this error.\")\n    })\n    @PostMapping(value = \"/runtime/tasks/{taskId}/identitylinks\", produces = \"application/json\")\n    @ResponseStatus(HttpStatus.CREATED)\n    public RestIdentityLink createIdentityLink(@ApiParam(name = \"taskId\") @PathVariable(\"taskId\") String taskId, @RequestBody RestIdentityLink identityLink) {\n\n        Task task = getTaskFromRequestWithoutAccessCheck(taskId);\n\n        if (identityLink.getGroup() == null && identityLink.getUser() == null) {\n            throw new FlowableIllegalArgumentException(\"A group or a user is required to create an identity link.\");\n        }\n\n        if (identityLink.getGroup() != null && identityLink.getUser() != null) {\n            throw new FlowableIllegalArgumentException(\"Only one of user or group can be used to create an identity link.\");\n        }\n\n        if (identityLink.getType() == null) {\n            throw new FlowableIllegalArgumentException(\"The identity link type is required.\");\n        }\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.createTaskIdentityLink(task, identityLink);\n        }\n\n        if (identityLink.getGroup() != null) {\n            taskService.addGroupIdentityLink(task.getId(), identityLink.getGroup(), identityLink.getType());\n        } else {\n            taskService.addUserIdentityLink(task.getId(), identityLink.getUser(), identityLink.getType());","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskIdentityLinkCollectionResource.java#L53-L89","documentation":"POST /runtime/tasks/{taskId}/identitylinks requires at least one of 'user' or 'group' in the payload. FlowableIllegalArgumentException is thrown when both are null because an identity link must point at a user or a group.","triggerScenarios":"POST /runtime/tasks/{taskId}/identitylinks with body like {\"type\":\"candidate\"} missing both 'user' and 'group'.","commonSituations":"Forms that let users pick either user or group but submit without any selection; JSON field name typos (e.g. 'userId' instead of 'user').","solutions":["Include exactly one of 'user' or 'group' in the request body","Fix field names to match the API ('user' and 'group', not 'userId'/'groupId')","Add client-side validation requiring a selection before submission"],"exampleFix":"// before\n{\"type\": \"candidate\"}\n// after\n{\"type\": \"candidate\", \"user\": \"kermit\"}","handlingStrategy":"validation","validationCode":"if (!payload.user && !payload.group) {\n  throw new Error('identity link requires user or group');\n}","typeGuard":null,"tryCatchPattern":"try { ... } catch (e) { if (e.status === 400) showFormError('Select a user or a group'); else throw e; }","preventionTips":["Require a user or group selection in the UI","Use exact API field names 'user' and 'group'","Validate the payload before POST"],"tags":["rest","validation","flowable","identity-links"],"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"}