iflytek/astron-agent · error · IllegalArgumentException
Encrypted data cannot be empty
Error message
Encrypted data cannot be empty
What it means
WechatMessageCrypto.decryptMessage first guards that the encryptData parameter is non-blank; if it has no text it throws IllegalArgumentException('Encrypted data cannot be empty'). This is a fail-fast input validation: there is nothing to decrypt, and the stub implementation (which currently returns mock data) cannot proceed.
Solutions
- Check the caller extracts the encrypted payload (Encrypt request param or <Encrypt> XML field) and passes it through.
- Ensure the WeChat console callback mode matches the expected encrypted mode.
- Add an upstream check returning HTTP 400 for blank payloads instead of relying on this exception.
- Note the class is a TODO stub: implement decryption via the official WXBizMsgCrypt (present in the same package) so real payloads decrypt correctly.
Example fix
// before
crypto.decryptMessage(sig, ts, nonce, request.getParameter("encrypt")); // may be null
// after
String enc = request.getParameter("encrypt");
if (enc == null || enc.isBlank()) {
return ResponseEntity.badRequest().build();
}
crypto.decryptMessage(sig, ts, nonce, enc); Defensive patterns
Strategy: validation
Validate before calling
if (!StringUtils.hasText(encryptData)) { return ResponseEntity.badRequest().body("missing encrypted payload"); } Try / catch
try { return crypto.decryptMessage(sig, ts, nonce, enc); } catch (IllegalArgumentException e) { return ResponseEntity.badRequest().body("encrypted data required"); } Prevention
- Extract the Encrypt param/XML field before invoking crypto
- Match the WeChat console encryption mode to your handler
- Return 400 early for blank callback payloads
- Replace the TODO stub with official WXBizMsgCrypt
When it happens
Trigger: Calling decryptMessage(msgSignature, timestamp, nonce, encryptData) with encryptData being null, empty string, or whitespace — e.g. the incoming request's encrypted payload parameter was missing or the <Encrypt> XML field was absent.
Common situations: WeChat callback configured in plaintext mode so no encrypted payload is sent; controller fails to extract the encrypted body/parameter before calling the service; a sender (or attacker/scanner) POSTs an empty callback to the endpoint.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/32a21bf2369cad5b.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/wechat/WechatMessageCrypto.java:38
public WechatMessageCrypto(String token, String encodingAesKey, String componentAppid) {
this.token = token;
this.encodingAesKey = encodingAesKey;
this.componentAppid = componentAppid;
}
/**
* Decrypt WeChat message
*
* @param msgSignature Message signature
* @param timestamp Timestamp
* @param nonce Random number
* @param encryptData Encrypted data
* @return Decrypted message
*/
public String decryptMessage(String msgSignature, String timestamp, String nonce, String encryptData) {
if (!StringUtils.hasText(encryptData)) {
throw new IllegalArgumentException("Encrypted data cannot be empty");
}
try {
// TODO: Implement actual WeChat message decryption logic here
// In actual projects, should use the official WeChat WXBizMsgCrypt class
log.warn("WeChat message decryption functionality needs to be implemented, currently returning mock data");
// Return mock decrypted data
return "<xml>" +
"<AppId><![CDATA[" + componentAppid + "]]></AppId>" +
"<InfoType><![CDATA[authorized]]></InfoType>" +
"<AuthorizerAppid><![CDATA[wx[example_appid]]]></AuthorizerAppid>" +
"<AuthorizationCode><![CDATA[auth_code_123]]></AuthorizationCode>" +
"<CreateTime>1234567890</CreateTime>" +
"</xml>";
} catch (Exception e) {
log.error("WeChat message decryption failed: msgSignature={}, timestamp={}, nonce={}",View on GitHub (pinned to 5e758547a8)