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
- Add the missing key with a non-null raw SQL fragment value next to @raw in the same object
- Check exact spelling/case of every key listed in @raw against the sibling keys
- If a key may legitimately be absent, either remove it from @raw or enable AbstractSQLConfig.ALLOW_MISSING_KEY_4_COMBINE (accepting the warning path)
- 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
- Generate @raw and its value keys from one builder variable so they cannot diverge
- Unit-test each raw fragment expression against a real DB in CI
- Treat @raw as SQL injection surface: whitelist fragments server-side
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
- Cannot convert value of type " + value.getClass().getName()
- 字符 " + function + " 不合法!
- 字符 " + method + " 不合法!函数的名称 function 不能为空且必须符合方法命名规范!总体必须为 f
- 字符 {} 不合法!远程函数不允许指定类名!且必须为 function(key0,key1,...) 这种单函数格式!\
- {}: { @key(): value } 对应存储过程 value 中字符 {} 不合法!`schema` 当有 `
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/12f27fda911e0062.
Report an issue: GitHub.