{"record":{"id":"cb8fe04103d07f8a","repo":"Tencent/APIJSON","slug":"name-if-value-value-string-jso","errorCode":null,"errorMessage":"{name}: { IF: value } 中 value 类型错误！只允许 String, JSONRequest！","messagePattern":"(.+?): (.+?) 中 value 类型错误！只允许 String, JSONRequest！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java","lineNumber":942,"sourceCode":"\t * @param <M>\n\t * @param <L>\n\t * @throws Exception\n\t */\n\tpublic static <T, M extends Map<String, Object>, L extends List<Object>> M parse(@NotNull final RequestMethod method\n\t\t\t, String name, M target, M real, String database, String datasource, String namespace, String catalog, String schema\n            , final IdCallback<T> idCallback, @NotNull Parser<T, M, L> parser, @NotNull OnParseCallback<T, M, L> callback) throws Exception {\n\t\tif (target == null) {\n\t\t\treturn null;\n\t\t}\n\n\t\tObject _if = target.get(IF.name());\n\t\tboolean ifIsStr = _if instanceof String && StringUtil.isNotEmpty(_if, true);\n\t\tM ifObj = ifIsStr == false && _if instanceof Map<?,?> ? (M) _if : null;\n//\t\t\t\t: (_if instanceof String ? new apijson.JSONMap((String) _if, \"\" /* \"throw new Error('')\" */ ) : null);\n\t\tif (ifObj == null && _if != null && ifIsStr == false) {\n//\t\t\tif (_if instanceof List<?>) {\n//\t\t\t}\n\t\t\tthrow new IllegalArgumentException(name + \": { \" + IF.name() + \": value } 中 value 类型错误！只允许 String, JSONRequest！\");\n\t\t}\n\n\t\t// 获取配置<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\t\tM type = get(target, TYPE.name());\n\t\tM verify = get(target, VERIFY.name());\n\t\tM insert = get(target, INSERT.name());\n\t\tM update = get(target, UPDATE.name());\n\t\tM replace = get(target, REPLACE.name());\n\n\t\tString exist = StringUtil.get(getString(target, EXIST.name()));\n\t\tString unique = StringUtil.get(getString(target, UNIQUE.name()));\n\t\tString remove = StringUtil.get(getString(target, REMOVE.name()));\n\t\tString must = StringUtil.get(getString(target, MUST.name()));\n\t\tString refuse = StringUtil.get(getString(target, REFUSE.name()));\n\n//\t\tObject code = target.get(CODE.name());\n\n\t\t// 移除字段<<<<<<<<<<<<<<<<<<<","sourceCodeStart":924,"sourceCodeEnd":960,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java#L924-L960","documentation":"Thrown while parsing a Request-table verification node: the IF key's value is neither a non-empty String nor a Map (JSONRequest). IF is a conditional guard (expression string or nested condition object); any other JSON type is a configuration error.","triggerScenarios":"A Request table / verify config entry like \"IF\": 123, \"IF\": true, \"IF\": [], or \"IF\": \"\" — anything that is not a usable String or a JSON object.","commonSituations":"Hand-editing the Request table's JSON config and using a number/boolean for IF; copying a condition array from another tool into IF; an ORM serializing a condition object into a list.","solutions":["Set IF to a condition string (\"IF\":\"role = ADMIN\") or a nested condition object (\"IF\": {\">\": {...}})","Remove the IF key entirely if no condition is needed","Reload/re-cache the Request table config after fixing it"],"exampleFix":"-- before (Request table config)\n{\"IF\": [1,2]}\n-- after\n{\"IF\": \"userId = 82001\"}","handlingStrategy":"validation","validationCode":"function validateIfValue(v) {\n  const ok = v == null || (typeof v === 'string' && v.trim() !== '') || (typeof v === 'object' && !Array.isArray(v));\n  if (!ok) throw new Error('IF must be a non-empty String or a JSON object');\n}","typeGuard":"const isValidIf = (v) => v == null || (typeof v === 'string' && v !== '') || (v != null && typeof v === 'object' && !Array.isArray(v));","tryCatchPattern":null,"preventionTips":["Lint Request-table JSON configs in CI (schema-check IF/TYPE/VERIFY/REFUSE/MUST values)","Never store arrays or booleans under IF"],"tags":["apijson","config","request-table","if-condition"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}