binarywang/WxJava · error · IllegalArgumentException
微信开放平台 secret 不能为空
Error message
微信开放平台 secret 不能为空
What it means
Thrown by `configApp` in the Spring Boot multi-account Open Platform starter when a tenant's `secret` (componentAppSecret) is blank. The component secret is required to exchange for component tokens. It is an IllegalArgumentException thrown right after the appId check.
Source
Thrown at spring-boot-starters/wx-java-open-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/configuration/services/AbstractWxOpenConfiguration.java:101
}
wxOpenService.setWxOpenConfigStorage(configStorage);
return wxOpenService;
}
private void configApp(WxOpenInMemoryConfigStorage config, WxOpenSingleProperties appProperties) {
String appId = appProperties.getAppId();
String secret = appProperties.getSecret();
String token = appProperties.getToken();
String aesKey = appProperties.getAesKey();
String apiHostUrl = appProperties.getApiHostUrl();
String accessTokenUrl = appProperties.getAccessTokenUrl();
// appId 和 secret 是必需的
if (StringUtils.isBlank(appId)) {
throw new IllegalArgumentException("微信开放平台 appId 不能为空");
}
if (StringUtils.isBlank(secret)) {
throw new IllegalArgumentException("微信开放平台 secret 不能为空");
}
config.setComponentAppId(appId);
config.setComponentAppSecret(secret);
if (StringUtils.isNotBlank(token)) {
config.setComponentToken(token);
}
if (StringUtils.isNotBlank(aesKey)) {
config.setComponentAesKey(aesKey);
}
// 设置URL配置
config.setApiHostUrl(StringUtils.trimToNull(apiHostUrl));
config.setAccessTokenUrl(StringUtils.trimToNull(accessTokenUrl));
}
private void configHttp(WxOpenInMemoryConfigStorage config, WxOpenMultiProperties.ConfigStorage storage) {
String httpProxyHost = storage.getHttpProxyHost();
Integer httpProxyPort = storage.getHttpProxyPort();View on GitHub (pinned to 1c43293a3c)
Solutions
- Provide a non-blank `secret` for the tenant.
- If using env vars, ensure the variable is present in the deployment environment.
- Restart; the check passes once StringUtils.isBlank(secret) is false.
Example fix
# before
wx.open.apps:
tenant-a: { appId: wxopen001 } # secret missing -> throws
# after
wx.open.apps:
tenant-a: { appId: wxopen001, secret: ${WXOPEN_SECRET} } Defensive patterns
Strategy: validation
Validate before calling
// Open multi: assert secret present per tenant
for (WxOpenSingleProperties p : appsMap.values()) {
if (StringUtils.isBlank(p.getSecret())) {
throw new IllegalArgumentException("Open platform secret is required for tenant " + p.getAppId());
}
} Prevention
- Never commit real secrets; supply via env/secrets manager.
- Fail fast at startup if any secret resolves blank.
- Rotate secrets and update both client config and server.
When it happens
Trigger: An entry under `wx.open.apps` whose `secret` is missing/blank/whitespace, regardless of whether appId is set.
Common situations: Secret omitted in YAML; secret sourced from an env var that is not exported in the runtime environment; secret redacted before deploy.
Related errors
- 微信开放平台 appId 不能为空
- 请确保微信开放平台配置 appId 的唯一性
- 请确保微信视频号配置 appId 的唯一性
- 请确保企业微信配置唯一性[{corpId}]
- 请确保微信小程序配置 appId 的唯一性
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/5c1449c63a376805.
Report an issue: GitHub.