{"record":{"id":"a73a6893318ceff5","repo":"flowable/flowable-engine","slug":"id-cannot-be-null-a73a68","errorCode":null,"errorMessage":"Id cannot be null.","messagePattern":"Id cannot be null\\.","errorType":"http","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserCollectionResource.java","lineNumber":152,"sourceCode":"        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessUserInfoWithQuery(query);\n        }\n\n        return paginateList(allRequestParams, query, \"id\", properties, restResponseFactory::createUserResponseList);\n    }\n\n    @ApiOperation(value = \"Create a user\", tags = { \"Users\" }, code = 201)\n    @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());","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserCollectionResource.java#L134-L170","documentation":"UserCollectionResource.createUser validates that UserRequest.id is non-null before creating the user, throwing FlowableIllegalArgumentException (HTTP 400). Flowable users require a caller-supplied unique id, which becomes the primary identifier in ACT_ID_USER.","triggerScenarios":"POST /identity/users with a JSON body missing the \"id\" field, e.g. {\"firstName\":\"John\",\"lastName\":\"Doe\",\"email\":\"jdoe@example.com\"}.","commonSituations":"Assuming the server auto-generates ids from the email; DTO field name mismatch (username vs id) yielding null after Jackson binding; script building the payload conditionally and skipping the id.","solutions":["Include a non-null \"id\" in the POST /identity/users body (optionally equal to the username).","Map the client's username field to the \"id\" JSON property.","Validate required fields client-side before sending."],"exampleFix":"// before\nPOST /identity/users {\"firstName\":\"John\",\"lastName\":\"Doe\",\"email\":\"jdoe@example.com\"}\n// after\nPOST /identity/users {\"id\":\"jdoe\",\"firstName\":\"John\",\"lastName\":\"Doe\",\"email\":\"jdoe@example.com\"}","handlingStrategy":"validation","validationCode":"if (userRequest == null || userRequest.getId() == null || userRequest.getId().isBlank()) {\n    throw new IllegalArgumentException(\"User id is required before POST /identity/users\");\n}","typeGuard":"boolean hasId(UserRequest r) { return r != null && r.getId() != null && !r.getId().isEmpty(); }","tryCatchPattern":null,"preventionTips":["Map username to the \"id\" JSON property in client DTOs.","Validate required fields before serialization.","Use the same userId for creation, task assignment and queries."],"tags":["rest-api","validation","user","bad-request"],"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"}