iflytek/astron-agent · error · BusinessException
PARAMS_ERROR
PARAMS_ERROR
Error message
PARAMS_ERROR
What it means
PARAMS_ERROR is thrown by WechatThirdpartyServiceImpl.buildAuthUrl when either preAuthCode or redirectUrl is blank (StringUtils.hasText fails). The method cannot construct the WeChat component login page URL without both values.
Solutions
- Ensure getPreAuthCode succeeded (non-blank) before calling buildAuthUrl; propagate its errors instead of passing blanks
- Set/verify the configured redirectUrl (application property or request param) is non-empty at the call site
- Add early validation at the controller layer to return a clear message about which parameter is missing
- If preAuthCode is intermittently blank, check Redis cache and the component token pipeline feeding getPreAuthCode
Example fix
// before
buildAuthUrl(preAuthCode, appid, redirectUrl); // preAuthCode may be blank
// after
if (!StringUtils.hasText(preAuthCode)) {
preAuthCode = wechatThirdpartyService.getPreAuthCode();
}
Assert.hasText(redirectUrl, "redirectUrl must be configured");
buildAuthUrl(preAuthCode, appid, redirectUrl); Defensive patterns
Strategy: validation
Validate before calling
// guard before calling
if (!StringUtils.hasText(preAuthCode)) {
preAuthCode = wechatThirdpartyService.getPreAuthCode();
}
if (!StringUtils.hasText(redirectUrl)) {
throw new IllegalArgumentException("redirectUrl must be configured");
} Try / catch
try {
String url = wechatThirdpartyService.buildAuthUrl(preAuthCode, appid, redirectUrl);
} catch (BusinessException e) {
if (ResponseEnum.PARAMS_ERROR.getCode().equals(e.getCode())) {
// re-fetch preAuthCode and/or fix redirectUrl config, then retry once
}
throw e;
} Prevention
- Fetch preAuthCode immediately before building the auth URL
- Externalize redirectUrl into config with a startup validation check
- Validate inputs at the controller boundary with clear field-level messages
When it happens
Trigger: Calling buildAuthUrl with null or empty-string preAuthCode (e.g. upstream getPreAuthCode failed silently or cache empty) or a null/blank redirectUrl from the caller.
Common situations: Pre-auth code expired and cache returned empty before the check upstream; caller forgot to pass the configured redirect/callback URL; property not set so null flows through; race where preAuthCode fetch failed but error was swallowed.
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/03cac66df30c1599.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/WechatThirdpartyServiceImpl.java:92
// Call WeChat API to get pre-authorization code
preAuthCode = requestPreAuthCodeFromWechat(componentAccessToken);
// Cache pre-authorization code (short-term cache to prevent duplicate requests)
bucket.set(preAuthCode, PRE_AUTH_CODE_EXPIRE);
log.info("Got new pre-auth code: botId={}, appid={}", botId, appid);
}
// Set pre-binding status to prevent official account from being bound to multiple bots
setPreBindStatus(appid, botId, uid);
return preAuthCode;
}
@Override
public String buildAuthUrl(String preAuthCode, String appid, String redirectUrl) {
if (!StringUtils.hasText(preAuthCode) || !StringUtils.hasText(redirectUrl)) {
throw new BusinessException(ResponseEnum.PARAMS_ERROR);
}
String authUrl = String.format(
"https://mp.weixin.qq.com/cgi-bin/componentloginpage?" +
"component_appid=%s&pre_auth_code=%s&redirect_uri=%s&auth_type=1",
componentAppid, preAuthCode, redirectUrl);
log.info("Building WeChat authorization URL: appid={}, redirectUrl={}", appid, redirectUrl);
return authUrl;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void handleAuthorizedCallback(WechatAuthCallbackDto callbackData) {
log.info("Handling WeChat authorization success callback: authorizerAppid={}", callbackData.getAuthorizerAppid());
String authorizerAppid = callbackData.getAuthorizerAppid();
if (!StringUtils.hasText(authorizerAppid)) {View on GitHub (pinned to 5e758547a8)