{"record":{"id":"7b25d29148c16656","repo":"paascloud/paascloud-master","slug":"uac10012001-7b25d2","errorCode":"UAC10012001","errorMessage":"角色ID不能为空","messagePattern":"角色ID不能为空","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/web/admin/UacRoleMainController.java","lineNumber":120,"sourceCode":"\t\tuacRoleService.batchDeleteByIdList(deleteIdList);\n\t\treturn WrapMapper.ok();\n\t}\n\n\t/**\n\t * 修改角色状态.\n\t *\n\t * @param modifyStatusDto the modify status dto\n\t *\n\t * @return the wrapper\n\t */\n\t@LogAnnotation\n\t@PostMapping(value = \"/modifyRoleStatusById\")\n\t@ApiOperation(httpMethod = \"POST\", value = \"根据角色Id修改角色状态\")\n\tpublic Wrapper modifyUacRoleStatusById(@ApiParam(name = \"modifyRoleStatusDto\", value = \"修改角色状态数据\") @RequestBody ModifyStatusDto modifyStatusDto) {\n\t\tlogger.info(\"根据角色Id修改角色状态 modifyStatusDto={}\", modifyStatusDto);\n\t\tLong roleId = modifyStatusDto.getId();\n\t\tif (roleId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012001);\n\t\t}\n\n\t\tLoginAuthDto loginAuthDto = getLoginAuthDto();\n\t\tLong userId = loginAuthDto.getUserId();\n\n\t\tUacRoleUser ru = uacRoleUserService.getByUserIdAndRoleId(userId, roleId);\n\n\t\tif (ru != null && UacRoleStatusEnum.DISABLE.getType().equals(modifyStatusDto.getStatus())) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012002);\n\t\t}\n\n\t\tUacRole uacRole = new UacRole();\n\t\tuacRole.setId(roleId);\n\t\tuacRole.setStatus(modifyStatusDto.getStatus());\n\t\tuacRole.setUpdateInfo(loginAuthDto);\n\n\t\tint result = uacRoleService.update(uacRole);\n\t\treturn super.handleResult(result);","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/web/admin/UacRoleMainController.java#L102-L138","documentation":"UacBizException with code UAC10012001 thrown by UacRoleMainController.modifyUacRoleStatusById when the ModifyStatusDto request body has a null id, meaning no role was targeted for the status change. The controller guards every role-status mutation on a non-null roleId before doing any lookup, so the request is rejected before touching the database.","triggerScenarios":"POST /modifyRoleStatusById with a JSON body whose 'id' field is missing or null, e.g. {\"status\": \"DISABLE\"}. Also occurs when a client sends an empty body {} or omits the id during a partial update.","commonSituations":"Frontend form only submits the status field and forgets the hidden roleId; API consumers copy-pasting a curl example without an id; deserialization producing null id when the JSON key is misspelled (e.g. 'roleId' instead of 'id').","solutions":["Include the role's id in the request body: {\"id\": 123, \"status\": \"DISABLE\"}","Verify the client serializes the ModifyStatusDto with the exact field name 'id'","Add client-side required-field validation before submitting the form","Return a 400-level validation error from the frontend instead of calling the API with incomplete data"],"exampleFix":"// before\n{\"status\": \"DISABLE\"}\n// after\n{\"id\": 123, \"status\": \"DISABLE\"}","handlingStrategy":"validation","validationCode":"if (!dto.id) { throw new Error('roleId is required'); }\n// or Java: Preconditions.checkNotNull(modifyStatusDto.getId(), \"roleId is required\");","typeGuard":"function hasRoleId(dto) { return dto != null && typeof dto.id === 'number' && dto.id > 0; }","tryCatchPattern":null,"preventionTips":["Always include the role id in ModifyStatusDto payloads","Validate required fields on the client before submission","Check JSON key names match the DTO field 'id' exactly","Log the outgoing request body when debugging 400-style errors"],"tags":["rest-api","validation","null-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}