Tencent/APIJSON · error · IllegalArgumentException

后端 Request 表中 ALLOW_PARTIAL_UPDATE_FAIL:value 中 {key} 不合法!必须

Error message

后端 Request 表中 ALLOW_PARTIAL_UPDATE_FAIL:value 中 {key} 不合法!必须以 [] 结尾!

What it means

Thrown while parsing ALLOW_PARTIAL_UPDATE_FAIL in the server-side Request table config: this optional setting lists which 'Table[]' batch keys are allowed to partially fail (some rows succeed, others fail, transaction not rolled back). Every entry must be an array key ending with '[]' (e.g. 'User[]'); an entry without that suffix is rejected with IllegalArgumentException because partial-failure semantics only exist for batch array operations.

Source

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

		// 校验重复<<<<<<<<<<<<<<<<<<<
		String[] uniques = StringUtil.split(unique);
		if (uniques != null && uniques.length > 0) {
			long exceptId = getLongValue(real, finalIdKey);
			Map<String,Object> map = new HashMap<>();
			for (String u : uniques) {
				map.put(u, real.get(u));
			}
			verifyRepeat(name, map, exceptId, finalIdKey, parser);
		}
		// 校验重复>>>>>>>>>>>>>>>>>>>

		// 校验并配置允许批量增删改部分失败<<<<<<<<<<<<<<<<<<<
		String allowPartialUpdateFail = StringUtil.get(getString(target, ALLOW_PARTIAL_UPDATE_FAIL.name()));
		String[] partialFails = StringUtil.split(allowPartialUpdateFail);
		if (partialFails != null && partialFails.length > 0) {
			for (String key : partialFails) {
                if (isArrayKey(key) == false) {
                    throw new IllegalArgumentException("后端 Request 表中 " + ALLOW_PARTIAL_UPDATE_FAIL.name()
                            + ":value 中 " + key + " 不合法!必须以 [] 结尾!");
                }
                if (target.get(key) instanceof Collection == false) {
                    throw new IllegalArgumentException("后端 Request 表中 " + ALLOW_PARTIAL_UPDATE_FAIL.name()
                            + ":value 中 " + key + " 对应的 " + key + ":[] 不存在!");
                }

                // 可能 Table[] 和 Table:alias[] 冲突  int index = key.indexOf(":");
                // String k = index < 0 ? key.substring(0, key.length() - 2) : key.substring(0, index);
                String k = key.substring(0, key.length() - 2);
                if (k.isEmpty()) {
                    throw new IllegalArgumentException("后端 Request 表中 " + ALLOW_PARTIAL_UPDATE_FAIL.name()
                            + ":value 中 " + key + " 不合法![] 前必须有名字!");
                }

				AbstractSQLConfig.ALLOW_PARTIAL_UPDATE_FAIL_TABLE_MAP.putIfAbsent(k, "");
			}
		}

View on GitHub (pinned to 5284052872)

Solutions

  1. Fix the value in the Request table so every token ends with '[]': e.g. ALLOW_PARTIAL_UPDATE_FAIL = "User[]" or "User[],Moment[]".
  2. Verify with SQL: SELECT structure->'$.ALLOW_PARTIAL_UPDATE_FAIL' FROM Request WHERE ... and correct any token missing the suffix.
  3. If partial failure is not needed, remove ALLOW_PARTIAL_UPDATE_FAIL entirely (null/empty is skipped by the check).

Example fix

// before
{"INSERT":{"ALLOW_PARTIAL_UPDATE_FAIL":"User","User[]":[]}}
// after
{"INSERT":{"ALLOW_PARTIAL_UPDATE_FAIL":"User[]","User[]":[]}}
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern ARR_KEY = Pattern.compile("^\\w+\\[\\]$");
void checkPartialFailConfig(String value) {
  if (value == null || value.isEmpty()) return;
  for (String tok : value.split("[\\s,]+")) {
    if (!ARR_KEY.matcher(tok).matches())
      throw new IllegalStateException("ALLOW_PARTIAL_UPDATE_FAIL token '" + tok + "' must end with []");
  }
}

Try / catch

try { verifier.parse(...); }
catch (IllegalArgumentException e) {
  if (e.getMessage() != null && e.getMessage().contains("ALLOW_PARTIAL_UPDATE_FAIL")) {
    // backend config defect — fix the Request row; do not retry
    log.error("Fix Request table ALLOW_PARTIAL_UPDATE_FAIL: {}", e.getMessage());
  }
  throw e;
}

Prevention

When it happens

Trigger: Backend admin sets ALLOW_PARTIAL_UPDATE_FAIL in the Request table to a value like "User" or "User,Moment[]" — any token that does not end with '[]' — and the next request that goes through AbstractVerifier.parse for that config throws immediately during verification, before SQL runs.

Common situations: Copying an ALLOW_PARTIAL_UPDATE_FAIL example but omitting the '[]' suffix; editing the Request table by hand instead of using the documented format; a JSON serialisation step stripping '[]' from the key; upgrading APIJSON to a version that added this strict check on previously tolerated config.

Related errors


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