Tencent/APIJSON · error · IllegalArgumentException

{}: { @key(): value } 对应存储过程 value 中字符 `{} 不合法!`schema` 当有 `

Error message

{}: { @key(): value } 对应存储过程 value 中字符 `{} 不合法!`schema` 当有 ` 包裹时一定是首尾各一个,不能多也不能少!

What it means

extractSchema() backtick-pair branch: when the schema starts with a backtick, after stripping that first character the remaining string must have its last backtick exactly at the final position (i.e. exactly one closing backtick at the end). This throw fires when the schema begins with '`' but has no matching sole closing backtick at the end — e.g. '`schema' or '`sch`ema' — so the wrapper is unbalanced and the identifier is rejected.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java:709

	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 注入的符号!");
		}

		return sch;
	}


	/**
	 * @param method

View on GitHub (pinned to 5284052872)

Solutions

  1. Make the backtick wrapper symmetric: start with '`' and end with '`' with none in between: '`mydb`.my_proc(id)'.
  2. Prefer omitting backticks entirely for identifiers that only use letters, digits and underscores.
  3. Add a client-side check that the schema segment matches ^`?[A-Za-z0-9_]+`?$ before sending.

Example fix

// before
"@procedure()": "`mydb.my_proc(id)"
// after
"@procedure()": "`mydb`.my_proc(id)"
Defensive patterns

Strategy: validation

Validate before calling

boolean balancedBackticks(String sch) {
  if (!sch.startsWith("`")) return sch.indexOf('`') < 0;
  return sch.length() > 1 && sch.endsWith("`") && sch.indexOf('`', 1) == sch.length() - 1;
}

Type guard

function hasBalancedBackticks(s: string): boolean {
  if (!s.startsWith('`')) return !s.includes('`');
  return s.length > 1 && s.endsWith('`') && s.indexOf('`', 1) === s.length - 1;
}

Prevention

When it happens

Trigger: Stored procedure value strings such as '`mydb.func(id)' (missing closing backtick), '`my`db.func(id)' (extra backtick in the middle), or '`mydb`.x' variants where the second backtick is not terminal.

Common situations: Hand-typing quoted schema names and forgetting the closing '`'; string concatenation in front-end code dropping the trailing character; templating that collapses '``' into '`'.

Related errors


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