{"record":{"id":"8b91dccce5ef2857","repo":"flowable/flowable-engine","slug":"a-user-with-id-already-exists","errorCode":null,"errorMessage":"A user with id '' already exists.","messagePattern":"A user with id '' already exists\\.","errorType":"http","errorClass":"FlowableConflictException","httpStatus":409,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserCollectionResource.java","lineNumber":161,"sourceCode":"    @ApiResponses(value = {\n            @ApiResponse(code = 201, message = \"Indicates the user was created.\"),\n            @ApiResponse(code = 400, message = \"Indicates the id of the user was missing.\")\n\n    })\n    @PostMapping(value = \"/identity/users\", produces = \"application/json\")\n    @ResponseStatus(HttpStatus.CREATED)\n    public UserResponse createUser(@RequestBody UserRequest userRequest) {\n        if (userRequest.getId() == null) {\n            throw new FlowableIllegalArgumentException(\"Id cannot be null.\");\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.createUser(userRequest);\n        }\n\n        // Check if a user with the given ID already exists so we return a CONFLICT\n        if (identityService.createUserQuery().userId(userRequest.getId()).count() > 0) {\n            throw new FlowableConflictException(\"A user with id '\" + userRequest.getId() + \"' already exists.\");\n        }\n\n        User created = identityService.newUser(userRequest.getId());\n        created.setEmail(userRequest.getEmail());\n        created.setFirstName(userRequest.getFirstName());\n        created.setLastName(userRequest.getLastName());\n        created.setDisplayName(userRequest.getDisplayName());\n        created.setPassword(userRequest.getPassword());\n        created.setTenantId(userRequest.getTenantId());\n        identityService.saveUser(created);\n\n        return restResponseFactory.createUserResponse(created, true);\n    }\n\n}\n","sourceCodeStart":143,"sourceCodeEnd":177,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserCollectionResource.java#L143-L177","documentation":"Uniqueness violation in UserCollectionResource.createUser: a user with the requested id already exists in the identity store, so creation is refused (typically surfaced as a 409-style REST error). The existing user must be updated instead.","triggerScenarios":"Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserCollectionResource.java:161 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use PUT /identity/users/{userId} to update the existing user","Choose a unique user id","Check existence via GET /identity/users/{userId} before creating"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}