binarywang/WxJava · warning · RuntimeException
the responseContent cannot be empty
Error message
the responseContent cannot be empty
What it means
Thrown as RuntimeException when the response content passed to the private parse() method in WxMaImmediateDeliveryServiceImpl is blank (null, empty, or whitespace only). This is a defensive guard before JSON parsing in the immediate delivery (即时配送) service. Since parse() is a private internal method, this error indicates the WeChat API returned an empty body where content was expected.
Source
Thrown at weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java:228
WxMaBaseResponse response = WxMaGsonBuilder.create().fromJson(responseContent, WxMaBaseResponse.class);
if (response.getErrcode() == -1) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return response;
}
/**
* 解析响应.
*
* @param responseContent 响应内容
* @param valueType 类型
* @param <T> 类型
* @return 结果
* @throws WxErrorException 异常
*/
private <T extends WxMaDeliveryBaseResponse> T parse(final String responseContent, final Class<T> valueType) throws WxErrorException {
if (StringUtils.isBlank(responseContent)) {
throw new RuntimeException("the responseContent cannot be empty");
}
// 解析成Json对象
JsonObject jsonObject = GsonParser.parse(responseContent);
// 是否为微信错误响应 当 errcode==0 或者 不存在 还需要看 运力方 resultcode 状态码
JsonElement element = jsonObject.get(ERR_CODE);
// 正常响应下不会有该字段返回
if (!ObjectUtils.isEmpty(element) && SUCCESS_CODE != element.getAsInt()) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
// 是否为运力方错误响应
JsonElement delivery = jsonObject.get(SF_ERR_CODE);
if (!ObjectUtils.isEmpty(delivery) && SUCCESS_CODE != delivery.getAsInt()) {
throw new WxErrorException(jsonObject.get(SF_ERR_MSG).getAsString());
}
// 解析成对应响应对象
return WxMaDeliveryBaseResponse.fromJson(responseContent, valueType);
}
View on GitHub (pinned to 1c43293a3c)
Solutions
- This is an internal library guard — check network stability that may cause empty HTTP responses
- Verify the delivery API endpoint URL is correct and accessible from your server
- Check if WeChat is experiencing intermittent issues by retrying the same request
- Report as a library issue if WeChat legitimately returns empty bodies, so the library can handle it gracefully
Defensive patterns
Strategy: try-catch
Validate before calling
// Cannot validate directly — parse() is private and called internally. // Ensure network stability and retry at the delivery service call level.
Try / catch
try {
deliveryService.addOrder(request);
} catch (RuntimeException e) {
if (e.getMessage().contains("responseContent cannot be empty")) {
log.warn("WeChat returned empty response for delivery API — retrying");
// retry once or queue for later processing
} else {
throw e;
}
} Prevention
- Monitor delivery API response sizes and alert on empty responses
- Ensure stable network connectivity to WeChat delivery endpoints
- Implement retry logic at the delivery service call level for transient empty-response issues
- If empty responses are persistent, report to the library maintainers to handle gracefully
When it happens
Trigger: A delivery API method (e.g., addOrder, getOrder, cancelOrder) receives an empty or whitespace-only response body from WeChat and internally passes it to parse().
Common situations: Network issue causing truncated or empty response body; WeChat API returning empty body on certain server-side error conditions; HTTP client stripping the response body due to encoding issues; connection reset after headers but before body.
Related errors
- uri参数中不允许有access_token:
- 请确保微信公众号配置 appId 的唯一性
- 请确保微信小程序配置 appId 的唯一性
- 微信开放平台 appId 不能为空
- 微信开放平台 secret 不能为空
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/1330f32242c03d7e.
Report an issue: GitHub.