{"record":{"id":"7229d7c20a340ada","repo":"paascloud/paascloud-master","slug":"uac10012001-7229d7","errorCode":"UAC10012001","errorMessage":"角色ID不能为空","messagePattern":"角色ID不能为空","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"warning","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleActionServiceImpl.java","lineNumber":31,"sourceCode":"import java.util.List;\nimport java.util.Set;\n\n/**\n * The class Uac role action service.\n *\n * @author paascloud.net@gmail.com\n */\n@Service\n@Transactional(rollbackFor = Exception.class)\npublic class UacRoleActionServiceImpl extends BaseService<UacRoleAction> implements UacRoleActionService {\n\t@Resource\n\tprivate UacRoleActionMapper uacRoleActionMapper;\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic List<UacRoleAction> listByRoleId(Long roleId) {\n\t\tif (roleId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012001);\n\t\t}\n\t\tUacRoleAction roleMenu = new UacRoleAction();\n\t\troleMenu.setRoleId(roleId);\n\t\treturn uacRoleActionMapper.select(roleMenu);\n\t}\n\n\t@Override\n\tpublic void deleteByRoleId(Long roleId) {\n\t\tif (roleId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012001);\n\t\t}\n\t\tUacRoleAction roleMenu = new UacRoleAction();\n\t\troleMenu.setRoleId(roleId);\n\t\tuacRoleActionMapper.delete(roleMenu);\n\t}\n\n\t@Override\n\tpublic void insert(Long roleId, Set<Long> actionIdList) {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleActionServiceImpl.java#L13-L49","documentation":"UacBizException UAC10012001 ('角色ID不能为空' — role ID cannot be empty) thrown by UacRoleActionServiceImpl.listByRoleId when roleId is null. The service requires a concrete role id to query uac_role_action for the role's action permissions and refuses to run the query with a null key.","triggerScenarios":"Calling listByRoleId(null) — e.g. the REST request omitted roleId, the DTO field was not bound (wrong request param name/type), or upstream code passed an unset Long field.","commonSituations":"Frontend sends an assign-permission request before a role is selected; query parameter name mismatch between controller and client (@RequestParam(\"roleId\") vs 'id'); Long parsing of an empty string yielding null.","solutions":["Ensure the caller supplies a non-null roleId in the request (check the request body/params actually include it).","Add client-side validation requiring role selection before calling the permission-list API.","Check the controller's @RequestParam/@RequestBody binding so the JSON field name matches 'roleId'.","Default or reject empty roleId upstream with a clear 400 message instead of reaching the service."],"exampleFix":"// before: pass through whatever arrived\nList<UacRoleAction> actions = uacRoleActionService.listByRoleId(dto.getRoleId());\n// after: validate before calling\nif (dto.getRoleId() == null) {\n  throw new IllegalArgumentException(\"roleId is required\");\n}\nList<UacRoleAction> actions = uacRoleActionService.listByRoleId(dto.getRoleId());","handlingStrategy":"validation","validationCode":"if (roleId == null) {\n  throw new IllegalArgumentException(\"roleId is required\");\n}","typeGuard":"boolean hasRoleId(UacRoleActionQueryDto dto) { return dto != null && dto.getRoleId() != null; }","tryCatchPattern":"try {\n  return uacRoleActionService.listByRoleId(roleId);\n} catch (UacBizException e) {\n  if (\"UAC10012001\".equals(e.getCode())) { /* return empty list or 400 with message */ }\n  throw e;\n}","preventionTips":["Require role selection in the UI before querying its permissions.","Annotate DTOs with @NotNull so bean validation rejects nulls at the controller.","Verify request parameter names match the controller signature."],"tags":["validation","uac","role-action","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"}