{"record":{"id":"a0b39ea126c7edaf","repo":"binarywang/WxJava","slug":"errorcode-errormsg-a0b39e","errorCode":null,"errorMessage":"错误代码：{errorCode}, 错误信息：{errorMsg}","messagePattern":"错误代码：(.+?), 错误信息：(.+?)","errorType":"exception","errorClass":"WxErrorException","httpStatus":null,"severity":"error","filePath":"weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java","lineNumber":42,"sourceCode":"    super(requestHttp);\n  }\n\n  @Override\n  public WxMinishopImageUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {\n\n    RequestBody body = new MultipartBody.Builder()\n      .setType(MediaType.parse(\"multipart/form-data\"))\n      .addFormDataPart(\"media\",\n        file.getName(),\n        RequestBody.create(MediaType.parse(\"application/octet-stream\"), file))\n      .build();\n    Request request = new Request.Builder().url(uri).post(body).build();\n\n    Response response = requestHttp.getRequestHttpClient().newCall(request).execute();\n    String responseContent = response.body().string();\n    WxError error = WxError.fromJson(responseContent, wxType);\n    if (error.getErrorCode() != 0) {\n      throw new WxErrorException(error);\n    }\n    log.info(\"responseContent: {}\", responseContent);\n\n    return WxMinishopImageUploadResult.fromJson(responseContent);\n  }\n\n}\n","sourceCodeStart":24,"sourceCodeEnd":50,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestExecutor.java#L24-L50","documentation":"Thrown by the OkHttp minishop image-upload executor (file-based, not URL-based) when WeChat replies with a non-zero errcode. The executor uploads a file part as application/octet-stream, parses the response into WxError, and rethrows as WxErrorException when errorCode != 0. Functionally identical in shape to the generic media executor but returns a WxMinishopImageUploadResult.","triggerScenarios":"Uploading a product/store image file via the minishop endpoint with an expired access_token, a file that exceeds the minishop size limit, an unsupported image format, or when the response body is a non-JSON error page.","commonSituations":"access_token expired between requests; image too large or wrong format (e.g. webp where jpg/png expected); filename with no extension; gateway returning HTML on overload.","solutions":["Inspect e.getError().getErrorCode()/getErrorMsg() for the specific WeChat code.","Confirm the access_token is valid before uploading.","Validate image size and format against the minishop documentation before posting.","Ensure you are calling the minishop-specific executor with the minishop URL constant."],"exampleFix":"// before\nWxMinishopImageUploadResult r = service.execute(url, file);\n// after\ntry {\n  WxMinishopImageUploadResult r = service.execute(url, file);\n} catch (WxErrorException e) {\n  log.error(\"minishop image upload errcode={} msg={}\",\n    e.getError().getErrorCode(), e.getError().getErrorMsg());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"File f = ...;\nif (f == null || !f.exists() || f.length() <= 0) {\n  throw new IllegalArgumentException(\"image file required\");\n}\n// check extension against minishop supported formats\nString name = f.getName().toLowerCase();\nif (!name.endsWith(\".jpg\") && !name.endsWith(\".png\")) {\n  throw new IllegalArgumentException(\"unsupported image format\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  WxMinishopImageUploadResult r = service.execute(uri, file);\n} catch (WxErrorException e) {\n  log.error(\"errcode={} msg={}\", e.getError().getErrorCode(), e.getError().getErrorMsg());\n  throw e;\n}","preventionTips":["Validate image size/format before posting.","Keep access_token fresh.","Use the minishop-specific executor and URL constant."],"tags":["weixin-api","okhttp","minishop","media-upload","network"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}