{"record":{"id":"fd7508fc335471c3","repo":"flowable/flowable-engine","slug":"id-cannot-be-null-fd7508","errorCode":null,"errorMessage":"Id cannot be null.","messagePattern":"Id cannot be null\\.","errorType":"http","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-idm-rest/src/main/java/org/flowable/idm/rest/service/api/user/UserCollectionResource.java","lineNumber":149,"sourceCode":"        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessUserInfoWithQuery(query);\n        }\n\n        return paginateList(allRequestParams, query, \"id\", properties, idmRestResponseFactory::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 = \"/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        // 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        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.createNewUser(created);\n        }\n        ","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-rest/src/main/java/org/flowable/idm/rest/service/api/user/UserCollectionResource.java#L131-L167","documentation":"FlowableIllegalArgumentException thrown by POST /flowable-idm-service/users when the request body has no 'id' field. The user id is the primary key of the identity model in Flowable, so a user cannot be created without it; the API rejects the request as a 400 bad request.","triggerScenarios":"POST /users with a JSON body like {\"firstName\":\"...\"} missing 'id', or with 'id': null — typical when the client generates the id after the call or omits it for 'auto-generated' assumptions.","commonSituations":"Frontend forms that only collect email/name; clients migrating from systems that auto-generate user ids; serialization drops empty fields so id is silently removed from the payload.","solutions":["Include a non-null 'id' in the UserRequest JSON body before POSTing","Generate the id client-side (e.g. username or UUID) before the create call","Validate the request payload on the client and fail fast when id is absent","If the intent was to update, use PUT /users/{userId} instead"],"exampleFix":"// before\n{\"firstName\":\"John\",\"lastName\":\"Doe\",\"email\":\"j@d.com\"}\n// after\n{\"id\":\"jdoe\",\"firstName\":\"John\",\"lastName\":\"Doe\",\"email\":\"j@d.com\"}","handlingStrategy":"validation","validationCode":"// client-side guard before POST /users\nfunction assertCreatable(u) {\n  if (typeof u.id !== 'string' || u.id.length === 0) {\n    throw new Error('UserRequest.id is required');\n  }\n}","typeGuard":"function hasId(u) { return u !== null && typeof u === 'object' && typeof u.id === 'string' && u.id.length > 0; }","tryCatchPattern":null,"preventionTips":["Treat id as a mandatory input; generate it (username/UUID) upstream","Add schema validation (JSON Schema / bean validation) on the client payload","Remember Flowable does not auto-generate user ids"],"tags":["rest-api","validation","missing-field","user-creation","flowable"],"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"}