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

  1. Add every MUST-listed field to the request body (or a field@ reference like "pictureUrl@":"/User/avatar")
  2. If the field is genuinely optional, remove it from MUST in the Request table
  3. 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

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


AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14). Data as JSON: /api/errors/6ce167ff77de42f1. Report an issue: GitHub.