Tencent/APIJSON · error · IllegalArgumentException
{}: { @key(): value } 对应存储过程 value 中字符 {} 不合法!`schema` 当有 `
Error message
{}: { @key(): value } 对应存储过程 value 中字符 {} 不合法!`schema` 当有 ` 包裹时一定是首尾各一个,不能多也不能少! What it means
extractSchema() validates the schema part of a stored-procedure reference 'schema.function(arg)'. A backtick is allowed only as a wrapping pair at the very start and end. This branch fires when the first backtick appears at index > 0 (e.g. 'my`schema' or 'ab`'), meaning the schema contains a stray backtick that is not a leading wrapper, which the parser rejects to prevent malformed and injectable identifiers.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java:702
return fb;
}
public static void verifySchema(String sch, String table) {
extractSchema(sch, table);
}
public static String extractSchema(String sch, String table) {
if (StringUtil.isEmpty(sch)) {
return sch;
}
if (table == null) {
table = "Table";
}
int ind = sch.indexOf("`");
if (ind > 0) {
throw new IllegalArgumentException(table + ": { @key(): value } 对应存储过程 value 中字符 "
+ sch + " 不合法!`schema` 当有 ` 包裹时一定是首尾各一个,不能多也不能少!");
}
if (ind == 0) {
sch = sch.substring(1);
if (sch.indexOf("`") != sch.length() - 1) {
throw new IllegalArgumentException(table + ": { @key(): value } 对应存储过程 value 中字符 `"
+ sch + " 不合法!`schema` 当有 ` 包裹时一定是首尾各一个,不能多也不能少!");
}
sch = sch.substring(0, sch.length() - 1);
}
if (PATTERN_SCHEMA.matcher(sch).matches() == false || sch.contains("--")) {
throw new IllegalArgumentException(table + ": { @key(): value } 对应存储过程 value 中字符 "
+ sch + " 不合法!schema.function(arg) 中 schema 必须符合 数据库名/模式名 的命名规则!"
+ "一般只能传英文字母、数字、下划线!不允许 -- 等可能导致 SQL 注入的符号!");
}View on GitHub (pinned to 5284052872)
Solutions
- Use an unquoted schema name: 'schema.function(arg)' with only letters/digits/underscores.
- If quoting, wrap exactly: '`schema`.function(arg)' — one backtick at the very start and one at the very end of the schema, nothing else.
- Remove any embedded backticks from the schema identifier; if the DB schema truly contains such characters, rename it or map it server-side.
Example fix
// before "@procedure()": "my`db.my_proc(id)" // after "@procedure()": "`mydb`.my_proc(id)" // or simply mydb.my_proc(id)
Defensive patterns
Strategy: validation
Validate before calling
// schema must be bare identifier or a single leading+trailing backtick pair
private static final Pattern BARE = Pattern.compile("^[A-Za-z0-9_]+$");
String check(String sch) {
String s = sch.startsWith("`") ? sch.substring(1, sch.length() - 1) : sch;
if (!BARE.matcher(s).matches() || s.contains("`") || sch.indexOf('`') > 0 && !sch.startsWith("`")) throw new IllegalArgumentException("bad schema");
return sch;
} Type guard
function isValidSchema(s: string): boolean {
const t = s.startsWith('`') ? s.slice(1, -1) : s;
return /^[A-Za-z0-9_]+$/.test(t) && !t.includes('`') && (s.indexOf('`') === -1 || s.startsWith('`'));
} Prevention
- Prefer unquoted schema names made only of letters, digits, underscores.
- If quoting, template as '`' + name + '`' so the pair is always symmetric.
- Validate the schema segment client-side with a strict identifier regex.
When it happens
Trigger: A stored procedure / SQL function string like '@procedure()': 'my`db.func(...)' or 'sch`ema.method(key)' — any schema segment whose first '`' is not the first character.
Common situations: Copy-pasting MySQL identifiers that contain escaped backticks; typos when hand-writing quoted schema names; migrating table DDL with back-quoted names into request JSON without stripping quotes.
Related errors
- {}: { @key(): value } 对应存储过程 value 中字符 `{} 不合法!`schema` 当有 `
- {}: { @key(): value } 对应存储过程 value 中字符 {} 不合法!schema.functio
- Cannot convert value of type " + value.getClass().getName()
- 字符 " + function + " 不合法!
- 字符 " + method + " 不合法!函数的名称 function 不能为空且必须符合方法命名规范!总体必须为 f
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/7ad5142130a3cc02.
Report an issue: GitHub.