{"record":{"id":"88468395266f32fd","repo":"binarywang/WxJava","slug":"tagid-884683","errorCode":null,"errorMessage":"缺少tagId参数","messagePattern":"缺少tagId参数","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java","lineNumber":80,"sourceCode":"  public void delete(String tagId) throws WxErrorException {\n    String url = String.format(getWxCpTpConfigStorage().getApiUrl(TAG_DELETE), tagId);\n    this.mainService.get(url, null);\n  }\n\n  @Override\n  public List<WxCpTpTag> listAll() throws WxErrorException {\n    String url = getWxCpTpConfigStorage().getApiUrl(TAG_LIST);\n    String responseContent = this.mainService.get(url, null);\n    JsonObject tmpJson = GsonParser.parse(responseContent);\n    return WxCpGsonBuilder.create().fromJson(tmpJson.get(\"taglist\"), new TypeToken<List<WxCpTpTag>>() {\n      // do nothing\n    }.getType());\n  }\n\n  @Override\n  public WxCpTpTagGetResult get(String tagId) throws WxErrorException {\n    if (tagId == null) {\n      throw new IllegalArgumentException(\"缺少tagId参数\");\n    }\n\n    String url = String.format(getWxCpTpConfigStorage().getApiUrl(TAG_GET), tagId);\n    String responseContent = this.mainService.get(url, null);\n    return WxCpTpTagGetResult.deserialize(responseContent);\n  }\n\n  @Override\n  public WxCpTpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds)\n    throws WxErrorException {\n    String url = getWxCpTpConfigStorage().getApiUrl(TAG_ADD_TAG_USERS);\n    JsonObject jsonObject = new JsonObject();\n    jsonObject.addProperty(\"tagid\", tagId);\n    this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject);\n\n    return WxCpTpTagAddOrRemoveUsersResult.deserialize(this.mainService.post(url, jsonObject.toString()));\n  }\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImpl.java#L62-L98","documentation":"Thrown as IllegalArgumentException when the tagId parameter is null in WxCpTpTagServiceImpl.get(). This is a precondition check before the tagId is interpolated into the TAG_GET URL via String.format. Passing null would produce a malformed URL, so the method fails fast.","triggerScenarios":"Calling tagService.get(null) — the caller did not supply a tag ID. Also triggers if an upstream variable holding the tag ID is null due to a data flow bug.","commonSituations":"Null tag ID from database or upstream API response; forgot to pass tag ID from user input; business logic producing null under certain conditions.","solutions":["Pass a non-null tagId: tagService.get(\"1\")","Validate tagId before calling: if (tagId != null) tagService.get(tagId);","Trace the null source — check where the tagId variable is assigned"],"exampleFix":"// before\nString tagId = getTagIdFromRequest(); // may return null\ntagService.get(tagId);\n\n// after\nString tagId = getTagIdFromRequest();\nif (tagId == null) {\n  throw new IllegalArgumentException(\"tagId is required\");\n}\ntagService.get(tagId);","handlingStrategy":"validation","validationCode":"// Validate tagId before calling get()\nif (tagId == null || tagId.isEmpty()) {\n  throw new IllegalArgumentException(\"tagId must not be null or empty\");\n}\ntagService.get(tagId);","typeGuard":"private static boolean isValidTagId(String tagId) {\n  return tagId != null && !tagId.isEmpty();\n}","tryCatchPattern":"try {\n  tagService.get(tagId);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"tagId\")) {\n    log.warn(\"tagId was null, skipping tag query\");\n    return null;\n  }\n  throw e;\n}","preventionTips":["Always validate that required parameters are non-null before calling API methods","Use @NonNull annotations or Objects.requireNonNull on the calling side","Trace null sources to fix the root cause, not just the symptom"],"tags":["validation","weixin-cp","null-check","tag","tp"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}