Tencent/APIJSON · error · IllegalArgumentException

POST 请求必须在Table内设置要保存的 key:value !

Error message

POST 请求必须在Table内设置要保存的 key:value !

What it means

For the OWNER role on a POST, verifyRole() reads config.getColumn() and config.getValues() to inject the visitor id; if either the column list or the values list is null/empty, IllegalArgumentException states that POST must set key:value inside the Table object. A POST without content cannot be ownership-stamped, so it is rejected before reaching the DB.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java:416

					}
					else if (id instanceof String) {
						if (StringUtil.isEmpty(id) || list.contains(id) == false) {
							throw new IllegalAccessException(visitorIdKey + " = " + id + " 的 " + table
									+ " 不允许 " + role + " 用户的 " + method.name() + " 请求!");
						}
					}
					else {
						throw new UnsupportedDataTypeException(table + ".id 类型错误,类型必须是 Long/String!");
					}
				}
			}
			break;
		case OWNER:
			if (config.getMethod() == POST) {
				List<String> c = config.getColumn();
				List<List<Object>> ovs = config.getValues();
				if ( (c == null || c.isEmpty()) || (ovs == null || ovs.isEmpty()) ) {
					throw new IllegalArgumentException("POST 请求必须在Table内设置要保存的 key:value !");
				}

				int index = c.indexOf(visitorIdKey);
				if (index >= 0) {
					Object oid;
					for (List<Object> ovl : ovs) {
						oid = ovl == null || index >= ovl.size() ? null : ovl.get(index);
						if (oid == null || StringUtil.get(oid).equals("" + visitorId) == false) {
							throw new IllegalAccessException(visitorIdKey + " = " + oid + " 的 " + table
									+ " 不允许 " + role + " 用户的 " + method.name() + " 请求!");
						}
					}
				}
				else {
					List<String> nc = new ArrayList<>(c);
					nc.add(visitorIdKey);
					config.setColumn(nc);

View on GitHub (pinned to 5284052872)

Solutions

  1. Put the data to insert inside the table object of the POST request (e.g. {"User": {"name":"x", "sex":1}}), not as a sibling or in a wrapper.
  2. Make required fields required in the client form so an empty POST cannot be serialized.
  3. If the intent was a query, use GET instead of POST.

Example fix

// before
{ "@role": "OWNER", "User": {} }

// after
{ "User": { "name": "apijson", "sex": 1 } }
Defensive patterns

Strategy: validation

Validate before calling

if ("POST".equals(method) && (columns == null || columns.isEmpty() || values == null || values.isEmpty())) {
    clientError("POST requires key:value inside the table object");
}

Type guard

boolean isNonEmptyPost(Map<String,Object> tableObj) { return tableObj != null && !tableObj.isEmpty(); }

Try / catch

catch (IllegalArgumentException e) when message contains "POST 请求必须" -> 400; require the user to fill at least one field.

Prevention

When it happens

Trigger: A POST request whose table object is empty ({}), or contains only non-column operators (e.g. only "@role" or conditions), so SQLConfig ends up with null/empty columns or values while the role is OWNER.

Common situations: Client builds POST body from a form that was fully optional and submitted empty; refactoring that moved the key:value payload outside the table object (sibling instead of inside); testing POST with a stub object; keys filtered out by request-format validation leaving an empty object.

Related errors


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