Tencent/APIJSON · error · ConflictException

REFUSE:value 中同时出现了 {rfs} 和 !{rfs} !不允许重复,也不允许一个 key 和取反 !ke

Error message

REFUSE:value 中同时出现了 {rfs} 和 !{rfs} !不允许重复,也不允许一个 key 和取反 !key 同时使用!

What it means

Thrown while parsing the Request-table REFUSE list: a plain key appears after the same key was already negated (!key seen earlier), i.e. both key and !key are configured. Refusing and allowing the same key at once is contradictory.

Source

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

		Set<String> refuseSet = new HashSet<String>();

		if (refuses != null && refuses.length > 0) {
			Set<String> notRefuseSet = new HashSet<String>();

			for (String rfs : refuses) {
				if (rfs == null) {  // StringUtil.isEmpty(rfs, true) {
					continue;
				}

				if (rfs.startsWith("!")) {
					rfs = rfs.substring(1);

					if (notRefuseSet.contains(rfs)) {
						throw new ConflictException(REFUSE.name() + ":value 中出现了重复的 !"
                                + rfs + " !不允许重复,也不允许一个 key 和取反 !key 同时使用!");
					}
					if (refuseSet.contains(rfs)) {
						throw new ConflictException(REFUSE.name() + ":value 中同时出现了 "
                                + rfs + " 和 !" + rfs + " !不允许重复,也不允许一个 key 和取反 !key 同时使用!");
					}

					if (rfs.equals("")) { // 所有非 MUST
                        // 对@key放行,@role,@column,自定义@position等, @key:{ "Table":{} } 不会解析内部
						for (String key : rkset) {
							if (key == null || key.startsWith("@") || notRefuseSet.contains(key)
                                    || mustSet.contains(key) || objKeySet.contains(key)) {
								continue;
							}
							// 支持id ref: id{}@
							if (key.endsWith("@") && mustSet.contains(key.substring(0, key.length() - 1))) {
								continue;
							}
							refuseSet.add(key);
						}
					}
					else {  // 排除 !key 后再禁传其它的

View on GitHub (pinned to 5284052872)

Solutions

  1. Keep only one form: either the key or its !key negation, never both
  2. Resolve the config-merge conflict at the source that generated the REFUSE value
  3. Document that !key in REFUSE means 'exclude this key from the refuse-all set'

Example fix

-- before
REFUSE="!pictureUrl,pictureUrl"
-- after
REFUSE="!pictureUrl"
Defensive patterns

Strategy: validation

Validate before calling

function lintRefuse(refuse) {
  const plain = new Set(), negated = new Set();
  for (let k of refuse.split(',')) {
    k = k.trim(); if (!k) continue;
    if (k.startsWith('!')) { negated.add(k.slice(1)); if (plain.has(k.slice(1))) throw new Error(`key and !key both present: ${k}`); }
    else { plain.add(k); if (negated.has(k)) throw new Error(`key and !key both present: ${k}`); }
  }
}

Prevention

When it happens

Trigger: REFUSE="!pictureUrl,pictureUrl" — the negation is processed first, then the plain key hits the refuseSet-contains check.

Common situations: Config merge conflict where one branch refused a key and another un-refused it by adding the negation; copy-paste of refuse rules across request rows; misunderstanding !key semantics (it means 'refuse everything except', not 'un-refuse').

Related errors


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