Tencent/APIJSON · error · UnsupportedOperationException

AbstractVerifier.ENABLE_VERIFY_CONTENT == false 时不支持校验请求传参内容

Error message

AbstractVerifier.ENABLE_VERIFY_CONTENT == false 时不支持校验请求传参内容!如需支持则设置 AbstractVerifier.ENABLE_VERIFY_CONTENT = true !

What it means

The static verifyRequest(...) — which validates request structure against the target structure (structure.sqlaragna/Request tables) — refuses to run when AbstractVerifier.ENABLE_VERIFY_CONTENT is false, throwing UnsupportedOperationException. Like ENABLE_VERIFY_ROLE, this is an opt-in switch; structure validation is a security feature that must be deliberately enabled.

Source

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

	 * @param datasource
	 * @param namespace
	 * @param catalog
	 * @param schema
	 * @param idCallback
	 * @param parser
	 * @return
	 * @param <T>
	 * @param <M>
	 * @param <L>
	 * @throws Exception
	 */
	public static <T, M extends Map<String, Object>, L extends List<Object>> M verifyRequest(
			@NotNull final RequestMethod method, final String name, final M target, final M request
            , final int maxUpdateCount, final String database, final String datasource, final String namespace
			, final String catalog, final String schema, final IdCallback<T> idCallback
			, @NotNull Parser<T, M, L> parser) throws Exception {
		if (ENABLE_VERIFY_CONTENT == false) {
			throw new UnsupportedOperationException("AbstractVerifier.ENABLE_VERIFY_CONTENT == false" +
                    " 时不支持校验请求传参内容!如需支持则设置 AbstractVerifier.ENABLE_VERIFY_CONTENT = true !");
		}

		Log.i(TAG, "verifyRequest  method = " + method  + "; name = " + name
				+ "; target = \n" + toJSONString(target)
				+ "\n request = \n" + toJSONString(request));

		if (target == null || request == null) {// || request.isEmpty()) {
			Log.i(TAG, "verifyRequest  target == null || request == null >> return null;");
			return null;
		}

		//已在 Verifier 中处理
		//		if (get(getString(request, apijson.JSONMap.KEY_ROLE)) == ADMIN) {
		//			throw new IllegalArgumentException("角色设置错误!不允许在写操作Request中传 " + name +
		//					":{ " + apijson.JSONMap.KEY_ROLE + ":admin } !");
		//		}

View on GitHub (pinned to 5284052872)

Solutions

  1. Set AbstractVerifier.ENABLE_VERIFY_CONTENT = true in your verifier's static initializer (together with ENABLE_VERIFY_ROLE if you also use role checks).
  2. If you do not want structure validation, remove/avoid the Request-table entries that trigger verifyRequest for your tags.
  3. Confirm the flag is set before the first request is served (static-init order in multi-module apps).

Example fix

// before
static { AbstractVerifier.ENABLE_VERIFY_ROLE = true; }

// after
static {
    AbstractVerifier.ENABLE_VERIFY_ROLE = true;
    AbstractVerifier.ENABLE_VERIFY_CONTENT = true;
}
Defensive patterns

Strategy: validation

Validate before calling

if (!AbstractVerifier.ENABLE_VERIFY_CONTENT && structureValidationRequired(tag)) {
    throw new IllegalStateException("Request-table structures exist but ENABLE_VERIFY_CONTENT is false");
}

Try / catch

catch (UnsupportedOperationException e) { 500 config error; ops enables ENABLE_VERIFY_CONTENT or removes the triggering structure rows.

Prevention

When it happens

Trigger: The framework (or a subclass such as the APIJSON framework's verifier) calls Verifier.verifyRequest(method, name, target, request, ...) — typically because a structure/Request table entry exists for the tag — while ENABLE_VERIFY_CONTENT was never set to true.

Common situations: Project relies on Request-table structure validation but the startup static block only enabled ENABLE_VERIFY_ROLE; upgrading APIJSON where defaults changed; copying example Request tables into a project whose verifier never enabled content verification.

Related errors


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