{"record":{"id":"bdf2239e6d400a20","repo":"binarywang/WxJava","slug":"100-100","errorCode":null,"errorMessage":"用户列表不能为空，不超过 100 个，若用户超过 100 个，请分批获取","messagePattern":"用户列表不能为空，不超过 100 个，若用户超过 100 个，请分批获取","errorType":"validation","errorClass":"WxRuntimeException","httpStatus":null,"severity":"warning","filePath":"weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java","lineNumber":48,"sourceCode":"public class WxCpOaServiceImpl implements WxCpOaService {\n  private final WxCpService mainService;\n\n  private static final int MONTH_SECONDS = 31 * 24 * 60 * 60;\n  private static final int USER_IDS_LIMIT = 100;\n\n  @Override\n  public String apply(WxCpOaApplyEventRequest request) throws WxErrorException {\n    String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(APPLY_EVENT),\n      request.toJson());\n    return GsonParser.parse(responseContent).get(\"sp_no\").getAsString();\n  }\n\n  @Override\n  public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, @NonNull Date startTime,\n                                              @NonNull Date endTime,\n                                              List<String> userIdList) throws WxErrorException {\n    if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) {\n      throw new WxRuntimeException(\"用户列表不能为空，不超过 \" + USER_IDS_LIMIT + \" 个，若用户超过 \" + USER_IDS_LIMIT + \" 个，请分批获取\");\n    }\n\n    long endTimestamp = endTime.getTime() / 1000L;\n    long startTimestamp = startTime.getTime() / 1000L;\n\n    if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp > MONTH_SECONDS) {\n      throw new WxRuntimeException(\"获取记录时间跨度不超过一个月\");\n    }\n\n    JsonObject jsonObject = new JsonObject();\n    JsonArray jsonArray = new JsonArray();\n\n    jsonObject.addProperty(\"opencheckindatatype\", openCheckinDataType);\n    jsonObject.addProperty(\"starttime\", startTimestamp);\n    jsonObject.addProperty(\"endtime\", endTimestamp);\n\n    for (String userid : userIdList) {\n      jsonArray.add(userid);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java#L30-L66","documentation":"Thrown (as unchecked WxRuntimeException) by getCheckinData() when the userIdList parameter is null or exceeds 100 entries. This is a pre-flight validation before the HTTP call to WeChat's checkin-data API, which itself enforces the same limit server-side.","triggerScenarios":"Passing null for userIdList, or passing a list with more than 100 user IDs to getCheckinData(). The check is `userIdList == null || userIdList.size() > 100`.","commonSituations":"Fetching checkin data for an entire department without paginating the user list; passing null because the caller forgot to populate the list; a downstream system providing a dynamically-sized list that occasionally exceeds 100.","solutions":["Split the user list into batches of at most 100 and call getCheckinData() per batch","Guard against null at the call site by initializing userIdList to an empty list or Collections.emptyList() when no users are needed","Add a pre-call validation utility that chunks lists: Lists.partition(userIdList, 100)"],"exampleFix":"// before\nList<WxCpCheckinData> data = oaService.getCheckinData(type, start, end, allUserIds); // allUserIds.size() = 250\n\n// after — batch in groups of 100\nList<WxCpCheckinData> allData = new ArrayList<>();\nfor (List<String> batch : Lists.partition(allUserIds, 100)) {\n  allData.addAll(oaService.getCheckinData(type, start, end, batch));\n}","handlingStrategy":"validation","validationCode":"// Validate before calling getCheckinData\nif (userIdList == null || userIdList.isEmpty()) {\n  throw new IllegalArgumentException(\"userIdList 不能为 null 或空\");\n}\nif (userIdList.size() > 100) {\n  // Batch automatically\n  List<List<String>> batches = Lists.partition(userIdList, 100);\n  // iterate batches...\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pre-validate list sizes against the 100-user limit before calling OA APIs","Use Lists.partition(userIdList, 100) (Guava) or a equivalent utility to batch automatically","Build a shared OA helper that encapsulates batching for all getCheckin*/getApproval* methods"],"tags":["wechat-cp","oa","checkin","validation","parameter-limit"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}