Tencent/APIJSON · error · IllegalArgumentException
{method}请求,{name} 里面不能缺少 {field} 等[{must}]内的任何字段!
Error message
{method}请求,{name} 里面不能缺少 {field} 等[{must}]内的任何字段! What it means
Thrown while merging a request with its Request-table template: a field listed in the MUST list is absent from the client's object (neither field nor field@ reference is present). MUST is the required-fields contract for the request.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java:976
// Object code = target.get(CODE.name());
// 移除字段<<<<<<<<<<<<<<<<<<<
String[] removes = StringUtil.split(remove);
if (removes != null && removes.length > 0) {
for (String r : removes) {
real.remove(r);
}
}
// 移除字段>>>>>>>>>>>>>>>>>>>
// 判断必要字段是否都有<<<<<<<<<<<<<<<<<<<
String[] musts = StringUtil.split(must);
Set<String> mustSet = new HashSet<String>();
if (musts != null && musts.length > 0) {
for (String s : musts) {
if (real.get(s) == null && real.get(s+"@") == null) { // 可能传null进来,这里还会通过 real.containsKey(s) == false) {
throw new IllegalArgumentException(method + "请求,"
+ name + " 里面不能缺少 " + s + " 等[" + must + "]内的任何字段!");
}
mustSet.add(s);
}
}
// 判断必要字段是否都有>>>>>>>>>>>>>>>>>>>
String[] sks = StringUtil.split(getString(real, KEY_STRING));
String[] trims = StringUtil.split(getString(real, KEY_TRIM));
List<String> stringKeyList = sks == null || sks.length <= 0 ? null : Arrays.asList(sks);
List<String> trimKeyList = trims == null || trims.length <= 0 ? null : Arrays.asList(trims);
Set<String> objKeySet = new HashSet<String>(); // 不能用tableKeySet,仅判断 Table:{} 会导致 key:{ Table:{} } 绕过判断
// 解析内容<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Set<Map.Entry<String, Object>> set = new LinkedHashSet<>(target.entrySet());View on GitHub (pinned to 5284052872)
Solutions
- Add every MUST-listed field to the request body (or a field@ reference like "pictureUrl@":"/User/avatar")
- If the field is genuinely optional, remove it from MUST in the Request table
- Check for typos/case mismatch between MUST entries and sent keys
Example fix
// before
{"User":{"name":"a"}} // MUST="name,pictureUrl"
// after
{"User":{"name":"a","pictureUrl":"https://..."}} Defensive patterns
Strategy: validation
Validate before calling
const MUST_FIELDS = ['name', 'pictureUrl']; // mirror of Request-table MUST
function assertMust(obj, fields) {
for (const f of fields) {
if (obj[f] == null && obj[f + '@'] == null) throw new Error(`missing required field: ${f}`);
}
} Try / catch
catch (e) { if (/不能缺少/.test(e.message)) { const m = e.message.match(/缺少 (\S+) 等\[(.*?)\]/); highlightMissingFields(m ? [m[1]] : parseList(m[2])); } else throw e; } Prevention
- Keep a client-side copy of MUST lists per endpoint and validate before send
- When the backend adds a MUST field, version the client update together with it
- Remember field@ references satisfy MUST too — use them for derived values
When it happens
Trigger: Request table row for e.g. POST User has MUST="name,pictureUrl" but the client posts {"User":{"name":"a"}} — pictureUrl (and pictureUrl@) missing.
Common situations: New required field added to MUST after clients shipped; frontend conditionally omits optional-looking fields; typo between the MUST entry and the key the client actually sends; field renamed in an API version bump.
Related errors
- 找不到 version: ${version}, method: ${method.name()}, tag: ${ta
- {method}请求,{name}/{key} 里面 {idKey},{idInKey},{idKey}{}@ 至少传其
- {name}: { IF: value } 中 value 类型错误!只允许 String, JSONRequest!
- {key}:value 的 value 不合法!类型必须是 OBJECT ,结构为 {} !
- REFUSE:value 中出现了重复的 !{rfs} !不允许重复,也不允许一个 key 和取反 !key 同时使用!
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/6ce167ff77de42f1.
Report an issue: GitHub.