binarywang/WxJava · error · WxErrorException
必填字段【%s】必须提供值!
Error message
必填字段【%s】必须提供值!
What it means
BeanUtils.checkRequiredFields reflects over a bean's fields annotated as required and collects any that are null/empty; if any are missing it throws WxErrorException listing them. This is used to validate request beans before sending them to WeChat, so required fields are enforced client-side with a clear message rather than failing opaquely server-side.
Source
Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java:60
// 另外一种情况是类型为字符串,但是字符串内容为空的,都认为是没有提供值
boolean isRequiredMissing = field.get(bean) == null
|| (field.get(bean) instanceof String
&& StringUtils.isBlank(field.get(bean).toString())
);
if (isRequiredMissing) {
requiredFields.add(field.getName());
}
}
field.setAccessible(isAccessible);
} catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
log.error(e.getMessage(), e);
}
}
if (!requiredFields.isEmpty()) {
String msg = String.format("必填字段【%s】必须提供值!", requiredFields);
log.debug(msg);
throw new WxErrorException(msg);
}
}
}
View on GitHub (pinned to 1c43293a3c)
Solutions
- Inspect the exception message — it names the exact missing required field(s).
- Populate the listed field(s) on the bean before retrying the API call.
- Use a builder/factory that enforces required fields at construction time.
- After WxJava upgrades, diff request beans for newly-required fields.
Example fix
// before — required field 'appId' left null WxSomeRequest req = new WxSomeRequest(); req.setSecret(secret); service.doSomething(req); // throws: 必填字段【appId】必须提供值! // after WxSomeRequest req = new WxSomeRequest(); req.setAppId(appId); req.setSecret(secret); service.doSomething(req);
Defensive patterns
Strategy: validation
Validate before calling
// Validate required fields before the call — let BeanUtils name them,
// or pre-check known required fields:
if (req.getAppId() == null || req.getSecret() == null) {
throw new IllegalArgumentException("appId/secret required");
} Try / catch
try {
service.doSomething(req);
} catch (WxErrorException e) {
if (e.getMessage() != null && e.getMessage().contains("必填字段")) {
// message names the missing field(s) — populate and retry
}
throw e;
} Prevention
- Read the exception message — it lists the exact missing required field(s).
- Use a builder/factory that enforces required fields at construction.
- After WxJava upgrades, diff request beans for newly-required fields.
When it happens
Trigger: Building a request bean (e.g. a WxMp/Channel/CP request object) and calling an API without populating one or more fields marked as required by the SDK's validation annotations.
Common situations: A new required field added in a WxJava upgrade that existing bean-construction code does not set; conditional logic that skips setting a required field for a particular request variant; copy-paste bean construction omitting a field.
Related errors
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/7659efb8383c8352.
Report an issue: GitHub.