{"record":{"id":"c6d71ff5987eac2e","repo":"Tencent/APIJSON","slug":"key-objkey-value-value-string","errorCode":null,"errorMessage":"${key}: { ${objKey}: value 中 value 类型错误，只能是 String 或 Map<String, Object> {} ！","messagePattern":"\\$\\{key\\}: \\{ \\$\\{objKey\\}: value 中 value 类型错误，只能是 String 或 Map<String, Object> \\{\\} ！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractParser.java","lineNumber":2348,"sourceCode":"\t\tSet<Entry<String, Object>> set = obj == null ? new HashSet<>() : obj.entrySet();\n\t\tfor (Entry<String, Object> objEntry : set) {\n\t\t\tString objKey = objEntry == null ? null : objEntry.getKey();\n\t\t\tif (objKey == null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tMap<String, Object> objAttrMap = new HashMap<>();\n\t\t\tobjAttrMap.put(KEY_METHOD, keyMethod);\n\t\t\tkeyObjectAttributesMap.put(objKey, objAttrMap);\n\n\t\t\tObject objVal = objEntry.getValue();\n\t\t\tMap<String, Object> objAttrJson = objVal instanceof Map<?, ?> ? JSON.getMap(obj, objKey) : null;\n\t\t\tif (objAttrJson == null) {\n\t\t\t\tif (objVal instanceof String) {\n\t\t\t\t\tobjAttrMap.put(KEY_TAG, \"\".equals(objVal) ? objKey : objVal);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new IllegalArgumentException(key + \": { \" + objKey + \": value 中 value 类型错误，只能是 String 或 Map<String, Object> {} ！\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tboolean hasTag = false;\n\t\t\t\tfor (Entry<String, Object> entry : objAttrJson.entrySet()) {\n\t\t\t\t\tString objAttrKey = entry == null ? null : entry.getKey();\n\t\t\t\t\tif (objAttrKey == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch (objAttrKey) {\n\t\t\t\t\t\tcase KEY_DATABASE:\n\t\t\t\t\t\tcase KEY_DATASOURCE:\n\t\t\t\t\t\tcase KEY_NAMESPACE:\n\t\t\t\t\t\tcase KEY_CATALOG:\n\t\t\t\t\t\tcase KEY_SCHEMA:\n\t\t\t\t\t\tcase KEY_VERSION:\n\t\t\t\t\t\tcase KEY_ROLE:","sourceCodeStart":2330,"sourceCodeEnd":2366,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java#L2330-L2366","documentation":"Same method-directive parsing as error 100, but one level deeper: after the directive value is accepted as a Map, one of its inner table entries has a value that is neither a String (per-table tag) nor a Map<String,Object> (per-table attributes). AbstractParser throws IllegalArgumentException naming the offending objKey.","triggerScenarios":"A request like \"@put\": {\"User\": 123} or \"@delete\": {\"Comment\": [1,2]} — the inner value under a table name inside the method directive map is a number/array/boolean instead of a tag string or attribute object.","commonSituations":"Developers pass a list of ids directly under a table inside the directive (thinking it is a batch payload); inconsistent JSON generation where inner values alternate between string tags and raw ids.","solutions":["Make each inner value a tag string: \"@put\": {\"User\": \"User\"}","Or an attribute object: \"@put\": {\"User\": {\"tag\": \"User\", \"method\": \"PUT\"}}","Move id lists into the table object of the main request body, not into the directive map"],"exampleFix":"// before\n{\"@delete\": {\"Comment\": [1, 2]}}\n// after\n{\"@delete\": {\"Comment\": \"Comment\"}, \"Comment\": {\"id{}\": [1, 2]}}","handlingStrategy":"validation","validationCode":"for (const [tbl, v] of Object.entries(req['@put'] ?? {})) {\n  if (!(typeof v === 'string' || (v && typeof v === 'object' && !Array.isArray(v)))) {\n    throw new Error(`@put:{${tbl}} value must be a tag string or object`);\n  }\n}","typeGuard":"const isInnerDirectiveValue = v => typeof v === 'string' || (v != null && typeof v === 'object' && !Array.isArray(v));","tryCatchPattern":"try { await client.crud(req); } catch (e) { if (e.message.includes('只能是 String 或 Map')) reportBadDirectiveEntry(req, e.message); else throw e; }","preventionTips":["Never place id arrays inside method-directive maps; use id{} in the table object","Unit-test request builders against directive shape"],"tags":["apijson","request-validation","batch-request"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}