{"record":{"id":"b343d9caadff0581","repo":"binarywang/WxJava","slug":"0-100-100","errorCode":null,"errorMessage":"可填充个数：0 ~ 100。超过100个需分批调用。","messagePattern":"可填充个数：0 ~ 100。超过100个需分批调用。","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java","lineNumber":99,"sourceCode":"\n  @Override\n  public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException {\n    return servicerOp(openKfid, userIdList, null, SERVICER_DEL);\n  }\n\n  @Override\n  public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList, List<String> departmentIdList) throws WxErrorException {\n    validateParameters(SERVICER_DEL, userIdList, departmentIdList);\n    return servicerOp(openKfid, userIdList, departmentIdList, SERVICER_DEL);\n  }\n\n  private void validateParameters(String uri, List<String> userIdList, List<String> departmentIdList) {\n    if ((userIdList == null || userIdList.isEmpty()) && (departmentIdList == null || departmentIdList.isEmpty())) {\n      throw new IllegalArgumentException(\"userid_list和department_id_list至少需要填其中一个\");\n    }\n    if (SERVICER_DEL.equals(uri)) {\n      if (userIdList != null && userIdList.size() > 100) {\n        throw new IllegalArgumentException(\"可填充个数：0 ~ 100。超过100个需分批调用。\");\n      }\n      if (departmentIdList != null && departmentIdList.size() > 100) {\n        throw new IllegalArgumentException(\"可填充个数：0 ~ 100。超过100个需分批调用。\");\n      }\n    } else {\n      if (userIdList != null && userIdList.size() > 100) {\n        throw new IllegalArgumentException(\"可填充个数：0 ~ 100。超过100个需分批调用。\");\n      }\n      if (departmentIdList != null && departmentIdList.size() > 20) {\n        throw new IllegalArgumentException(\"可填充个数：0 ~ 20。\");\n      }\n    }\n  }\n\n  private WxCpKfServicerOpResp servicerOp(String openKfid, List<String> userIdList, List<String> departmentIdList, String uri) throws WxErrorException {\n    String url = cpService.getWxCpConfigStorage().getApiUrl(uri);\n\n    JsonObject json = new JsonObject();","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java#L81-L117","documentation":"Thrown as IllegalArgumentException (unchecked) in validateParameters when the operation is SERVICER_DEL and userIdList contains more than 100 entries. WeChat's delete-servicer API caps userid_list at 100 per call; larger batches must be split. This guard fires before the HTTP request.","triggerScenarios":"Calling delServicer(openKfid, userIdList, departmentIdList) where userIdList.size() > 100 and the SERVICER_DEL path is taken. Happens during bulk removal of many customer service agents at once.","commonSituations":"Organization restructures and needs to remove a large set of servicers; developer passes the full list without chunking.","solutions":["Split userIdList into batches of 100 or fewer and call delServicer in a loop.","Use a utility like Lists.partition(userIdList, 100) (Guava) or manual subList partitioning.","Pre-validate the list size and warn the user if chunking is needed."],"exampleFix":"// before\nList<String> allUsers = getAllServicerUserIds(); // 250 entries\nservice.delServicer(openKfid, allUsers, null); // throws > 100\n\n// after\nList<List<String>> batches = partition(allUsers, 100);\nfor (List<String> batch : batches) {\n  service.delServicer(openKfid, batch, null);\n}","handlingStrategy":"validation","validationCode":"if (userIdList != null && userIdList.size() > 100) {\n    // partition into batches of 100\n    List<List<String>> batches = partition(userIdList, 100);\n    for (List<String> batch : batches) {\n        service.delServicer(openKfid, batch, null);\n    }\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Partition userIdList into batches of 100 before calling delServicer.","Use Guava Lists.partition or a custom partition utility for clean batch processing.","Log the number of batches for audit trail when processing large deletions."],"tags":["weixin-cp","kf","servicer","validation","limit","batch"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}