{"record":{"id":"a0667e68a9ef8faf","repo":"chinabugotech/hutool","slug":"unsupported-to-map-from-of-type-a0667e","errorCode":null,"errorMessage":"Unsupported to map from [{}] of type: {}","messagePattern":"Unsupported to map from \\[(.+?)\\] of type: (.+?)","errorType":"exception","errorClass":"ConvertException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/convert/impl/PairConverter.java","lineNumber":67,"sourceCode":"\tprotected Pair<?, ?> convertInternal(Object value) {\n\t\tMap map = null;\n\t\tif (value instanceof Map.Entry) {\n\t\t\tfinal Map.Entry entry = (Map.Entry) value;\n\t\t\tmap = MapUtil.of(entry.getKey(), entry.getValue());\n\t\t}else if (value instanceof Map) {\n\t\t\tmap = (Map) value;\n\t\t} else if (value instanceof CharSequence) {\n\t\t\tfinal CharSequence str = (CharSequence) value;\n\t\t\tmap = strToMap(str);\n\t\t} else if (BeanUtil.isReadableBean(value.getClass())) {\n\t\t\tmap = BeanUtil.beanToMap(value);\n\t\t}\n\n\t\tif (null != map) {\n\t\t\treturn mapToPair(pairType, keyType, valueType, map);\n\t\t}\n\n\t\tthrow new ConvertException(\"Unsupported to map from [{}] of type: {}\", value, value.getClass().getName());\n\t}\n\n\t/**\n\t * 字符串转单个键值对的Map，支持分隔符{@code :}、{@code =}、{@code ,}\n\t *\n\t * @param str 字符串\n\t * @return map or null\n\t */\n\tprivate static Map<CharSequence, CharSequence> strToMap(final CharSequence str) {\n\t\t// key:value  key=value  key,value\n\t\tfinal int index = StrUtil.indexOf(str, '=', 0, str.length());\n\n\t\tif (index > -1) {\n\t\t\treturn MapUtil.of(str.subSequence(0, index + 1), str.subSequence(index, str.length()));\n\t\t}\n\t\treturn null;\n\t}\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/convert/impl/PairConverter.java#L49-L85","documentation":"PairConverter.convertInternal accepts Map.Entry, Map, CharSequence containing a separator (= / : / ,), or a readable Bean (beanToMap). Any other source leaves map null and throws ConvertException naming value and class. Mirrors EntryConverter but targets hutool's Pair.","triggerScenarios":"Calling Convert.convert(scalar, Pair.class) where scalar is a Number, primitive, enum, or other non-structured object.","commonSituations":"Generic conversion pipeline hitting a Pair target with a scalar source; missing key/value structure.","solutions":["Wrap the value in a Pair, Map, or Map.Entry before converting.","If the source is a String, format it as \"key=value\" so strToMap parses it.","Provide a structured source (bean with key/value fields) the converter can read."],"exampleFix":"// before\nPair p = Convert.convert(42, Pair.class);\n\n// after - structured source\nPair p = Convert.convert(Pair.of(\"value\", 42), Pair.class);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Map) && !(value instanceof Map.Entry) && !(value instanceof Pair)\n        && !(value instanceof CharSequence) && !BeanUtil.isReadableBean(value.getClass())) {\n    value = Pair.of(\"value\", value);\n}\nConvert.convert(value, pairType);","typeGuard":"value instanceof Map || value instanceof Map.Entry || value instanceof Pair\n        || (value instanceof CharSequence && ((CharSequence)value).toString().matches(\".*[=:,].*\"))\n        || BeanUtil.isReadableBean(value.getClass())","tryCatchPattern":"try {\n    return Convert.convert(value, pairType);\n} catch (ConvertException e) {\n    if (e.getMessage().startsWith(\"Unsupported to map from\")) { /* wrap in a Pair */ }\n    else throw e;\n}","preventionTips":["Feed PairConverter a Pair, Map, Map.Entry, or \"key=value\" string.","Avoid routing scalars through Pair conversion."],"tags":["convert","pair","map","type-mismatch"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}