{"record":{"id":"1db01b234ea03724","repo":"binarywang/WxJava","slug":"outstoreid","errorCode":null,"errorMessage":"创建门店时outStoreId不能为空","messagePattern":"创建门店时outStoreId不能为空","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaIntracityServiceImpl.java","lineNumber":49,"sourceCode":"          .create();\n\n  private void checkStringResponse(String response) throws WxErrorException {\n    JsonObject respObj = GsonParser.parse(response);\n    if (respObj.get(ERR_CODE).getAsInt() != 0) {\n      throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));\n    }\n  }\n\n  @Override\n  public void apply() throws WxErrorException {\n    String response = this.wxMaService.post(Intracity.APPLY_URL, \"{}\");\n    checkStringResponse(response);\n  }\n\n  @Override\n  public String createStore(WxMaStore store) throws WxErrorException {\n    if (store.getOutStoreId() == null) {\n      throw new IllegalArgumentException(\"创建门店时outStoreId不能为空\");\n    }\n    if (store.getWxStoreId() != null) {\n      throw new IllegalArgumentException(\"创建门店时wxStoreId只能是null\");\n    }\n    String response = this.wxMaService.postWithSignature(Intracity.CREATE_STORE_URL, store);\n    Map<?, ?> map = gson.fromJson(response, Map.class);\n    return (String) map.get(\"wx_store_id\");\n  }\n\n  @Override\n  public void updateStore(WxMaStore store) throws WxErrorException {\n    if (store.getWxStoreId() == null && store.getOutStoreId() == null) {\n      throw new IllegalArgumentException(\"更新门店时wxStoreId 或 outStoreId 至少要有一个不为null\");\n    }\n    JsonObject request = new JsonObject();\n    Map<String, String> keys = new HashMap<>();\n    if (store.getWxStoreId() != null) {\n      keys.put(\"wx_store_id\", store.getWxStoreId());","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaIntracityServiceImpl.java#L31-L67","documentation":"Unchecked IllegalArgumentException from createStore(WxMaStore) when store.getOutStoreId() is null. outStoreId is the merchant-defined store identifier required on creation because WeChat does not assign it; wxStoreId is WeChat-assigned (returned on query) and is not a substitute.","triggerScenarios":"Calling intracityService.createStore(store) on a WxMaStore whose setOutStoreId(...) was never invoked.","commonSituations":"Building a WxMaStore from form/JSON input that omitted outStoreId; copying a store bean from a query result (which carries wxStoreId but may have a null outStoreId) and trying to create with it.","solutions":["Set outStoreId before calling createStore: store.setOutStoreId(\"your-unique-store-id\").","Validate outStoreId presence in your own DTO/form layer before constructing the WxMaStore."],"exampleFix":"// before\nWxMaStore store = new WxMaStore();\nstore.setStoreName(\"门店A\");\nintracityService.createStore(store);\n\n// after\nWxMaStore store = new WxMaStore();\nstore.setOutStoreId(\"STORE_001\");\nstore.setStoreName(\"门店A\");\nintracityService.createStore(store);","handlingStrategy":"validation","validationCode":"if (store.getOutStoreId() == null) {\n  throw new IllegalArgumentException(\"outStoreId required before createStore\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  id = intracityService.createStore(store);\n} catch (IllegalArgumentException e) {\n  // bad input — fix the caller, do not retry\n  throw e;\n}","preventionTips":["Make outStoreId a required parameter of your own store DTO/constructor.","Validate merchant-defined IDs at the controller/form layer before reaching the SDK."],"tags":["validation","intracity","store","illegal-argument","null-check"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}