iflytek/astron-agent · error · BusinessException
WECHAT_AUTH_FAILED
WECHAT_AUTH_FAILED
Error message
WECHAT_AUTH_FAILED
What it means
WECHAT_AUTH_FAILED wraps any exception raised while processing the WeChat authorization-success callback in handleAuthorizedCallback. The catch-all logs the real cause and rethrows as this generic business error, so the actual failure (DB write, cache, bot lookup) is hidden behind the wrapper.
Solutions
- Read the logged cause line ('WeChat authorization success callback handling failed: botId=..., authorizerAppid=...') to find the real exception
- Verify the botId from the pre-bind cache still exists and retry the authorization flow from the beginning if it was deleted
- Check Redis and database health at callback time; transient outages will surface as this error
- Make callback handling idempotent so duplicate WeChat callbacks don't trip constraint violations
Defensive patterns
Strategy: retry
Validate before calling
// verify bot and cache state before triggering authorization
ChatBotBase bot = chatBotBaseMapper.selectById(botId);
if (bot == null || !StringUtils.hasText(redissonClient.getBucket(preBindKey(botId)).get())) {
// restart the bind flow instead of waiting for the callback
} Try / catch
try {
wechatThirdpartyService.handleAuthorizedCallback(callbackData);
} catch (BusinessException e) {
if (ResponseEnum.WECHAT_AUTH_FAILED.getCode().equals(e.getCode())) {
log.error("auth callback failed; inspect wrapped cause in logs, then retry bind flow", e);
// restart authorization from getPreAuthCode/buildAuthUrl
}
throw e;
} Prevention
- Read the logged root cause — this error always wraps a specific exception
- Make callback handling idempotent for duplicate WeChat callbacks
- Keep bot records and pre-bind cache TTLs aligned with WeChat callback latency
- Monitor Redis/DB health; outages surface as this generic error
When it happens
Trigger: Any exception inside handleAuthorizedCallback: bot record not found for the bound botId, database update failures persisting the authorizer appid, Redisson cache operations failing, or cleanup of the pre-bind cache throwing.
Common situations: Redis unavailable during pre-bind cache cleanup; bot deleted between initiating authorization and the WeChat callback arriving; DB constraint violation when saving authorization info; WeChat re-sending an old/duplicate callback.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/21d9239ab0d6e434.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/WechatThirdpartyServiceImpl.java:137
return;
}
try {
// Initialize authorization token
initAuthorizationToken(authorizerAppid, callbackData.getAuthorizationCode());
// Establish binding relationship
// Note: Need to get user ID from pre-binding information, temporarily using placeholder
String uid = getUidFromPreBindInfo(authorizerAppid, botId);
botOffiaccountService.bind(botId, authorizerAppid, uid);
// Clean up cache
cleanupPreBindCache(authorizerAppid, botId);
log.info("WeChat authorization success callback handled successfully: botId={}, authorizerAppid={}", botId, authorizerAppid);
} catch (Exception e) {
log.error("WeChat authorization success callback handling failed: botId={}, authorizerAppid={}", botId, authorizerAppid, e);
throw new BusinessException(ResponseEnum.WECHAT_AUTH_FAILED);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void handleUpdateAuthorizedCallback(WechatAuthCallbackDto callbackData) {
log.info("Handling WeChat authorization update callback: authorizerAppid={}", callbackData.getAuthorizerAppid());
// Authorization update handling logic is similar to authorization success
handleAuthorizedCallback(callbackData);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void handleUnauthorizedCallback(WechatAuthCallbackDto callbackData) {
log.info("Handling WeChat unauthorized callback: authorizerAppid={}", callbackData.getAuthorizerAppid());
String authorizerAppid = callbackData.getAuthorizerAppid();View on GitHub (pinned to 5e758547a8)