Tencent/APIJSON · error · UnsupportedOperationException

@raw:value 的 value 中 {} 不合法!对应的 {}: value 在当前对象 {} 不存在或 valu

Error message

@raw:value 的 value 中 {} 不合法!对应的 {}: value 在当前对象 {} 不存在或 value = null,无法有效转为原始 SQL 片段!

What it means

@raw:"key1,key2" tells the parser to inline those keys' values as raw SQL fragments. Before building the SQLConfig, each referenced key is looked up in the current object (sqlRequest); if the value is missing or null, the key cannot be converted to a SQL fragment and UnsupportedOperationException is thrown (unless ALLOW_MISSING_KEY_4_COMBINE allows it, in which case only a warning is recorded).

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java:949


	@Override
	public SQLConfig<T, M, L> newSQLConfig(boolean isProcedure) throws Exception {
		String raw = Log.DEBUG == false || sqlRequest == null ? null : getString(sqlRequest, JSONMap.KEY_RAW);
		String[] keys = raw == null ? null : StringUtil.split(raw);
		if (keys != null && keys.length > 0) {
			boolean allow = AbstractSQLConfig.ALLOW_MISSING_KEY_4_COMBINE;

			for (String key : keys) {
				if (sqlRequest.get(key) != null) {
					continue;
				}

				String msg = "@raw:value 的 value 中 " + key + " 不合法!对应的 "
						+ key + ": value 在当前对象 " + name + " 不存在或 value = null,无法有效转为原始 SQL 片段!";

				if (allow == false) {
					throw new UnsupportedOperationException(msg);
				}

				if (parser instanceof AbstractParser) {
					((AbstractParser) parser).putWarnIfNeed(JSONMap.KEY_RAW, msg);
				}
				break;
			}
		}

		return newSQLConfig(method, table, alias, sqlRequest, joinList, isProcedure)
				.setParser(parser)
				.setObjectParser(this);
	}

	/**SQL 配置,for single object
	 * @return {@link #setSQLConfig(int, int, int)}
	 * @throws Exception
	 */

View on GitHub (pinned to 5284052872)

Solutions

  1. Add the missing key with a non-null raw SQL fragment value next to @raw in the same object
  2. Check exact spelling/case of every key listed in @raw against the sibling keys
  3. If a key may legitimately be absent, either remove it from @raw or enable AbstractSQLConfig.ALLOW_MISSING_KEY_4_COMBINE (accepting the warning path)
  4. Never rely on nested paths — @raw keys must exist in the current object only

Example fix

// before
{"User":{"@raw":"cond"}}
// after
{"User":{"@raw":"cond","cond":"`age` > 18"}}
Defensive patterns

Strategy: validation

Validate before calling

String[] keys = rawList.split(",");
for (String k : keys) {
  if (obj.get(k.trim()) == null) throw new IllegalStateException("@raw key missing value: " + k);
}

Type guard

boolean rawKeysAllPresent(Map<String,Object> obj, String rawSpec) {
  return Arrays.stream(rawSpec.split(",")).allMatch(k -> obj.get(k.trim()) != null);
}

Prevention

When it happens

Trigger: A request object containing "@raw":"expr" where the sibling key "expr" is absent or null, e.g. {"@raw":"fn","fn":null}. Also when the key name in @raw has a typo or whitespace so it does not match any sibling key.

Common situations: Building function expressions (e.g. "@raw":"func","func":"reverse(name)") and forgetting the companion value key; conditionally omitting the value key client-side when its expression is unavailable; renaming keys without updating the @raw list; relying on server-side defaults that leave the key null.

Related errors


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