{"record":{"id":"5b9ec0fe3b44ab98","repo":"apache/seatunnel","slug":"unsupported-convert-s-to-map-typedefine-s","errorCode":null,"errorMessage":"Unsupported convert %s to Map, typeDefine: %s","messagePattern":"Unsupported convert (.+?) to Map, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":158,"sourceCode":"            default:\n                throw new UnsupportedOperationException(\n                        \"Unsupported convert \"\n                                + value.getClass()\n                                + \" to \"\n                                + columnDefine.getDataType().getSqlType());\n        }\n    }\n\n    default Map convertMap(T typeDefine, Column columnDefine, Object value)\n            throws UnsupportedOperationException {\n        return convertMap((MapType) columnDefine.getDataType(), value);\n    }\n\n    default Map convertMap(MapType typeDefine, Object value) throws UnsupportedOperationException {\n        if (value instanceof Map) {\n            return (Map) value;\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Map, typeDefine: \" + typeDefine);\n    }\n\n    default Object[] convertArray(T typeDefine, Column columnDefine, Object value)\n            throws UnsupportedOperationException {\n        return convertArray((ArrayType) columnDefine.getDataType(), value);\n    }\n\n    default Object[] convertArray(ArrayType typeDefine, Object value)\n            throws UnsupportedOperationException {\n        if (value.getClass().isArray()) {\n            SeaTunnelDataType elementType = typeDefine.getElementType();\n\n            Object[] array = (Object[]) value;\n            for (int i = 0; i < array.length; i++) {\n                array[i] = convert(elementType, array[i]);\n            }\n            return array;","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L140-L176","documentation":"The default convertMap implementation accepts only java.util.Map instances; anything else triggers this UnsupportedOperationException. The typeDefine (MapType) is included to show which map schema was expected. It fires when a value routed to the MAP conversion path is not a Map at runtime.","triggerScenarios":"Calling convertMap(typeDefine, value) directly, or convert(...) with a MAP SqlType column, when value is a List, POJO, JSON string, or other non-Map object.","commonSituations":"Passing a JSON string that was never parsed into a Map; passing a List of key-value pairs hoping the converter will zip them; upstream framework (e.g. a NoSQL driver) returning its own document type not extending java.util.Map.","solutions":["Parse or convert the value to a java.util.Map before handing it to the converter (e.g. with Jackson for JSON strings).","If the value is a List of pairs, transform it into a LinkedHashMap manually.","Override convertMap in your converter subclass to accept the actual runtime type.","Verify the column SqlType is MAP; if the data is really a string, change the schema instead."],"exampleFix":"// before\nconverter.convertMap(mapType, jsonString);\n// after\nMap<String, Object> map = new ObjectMapper().readValue(jsonString, new TypeReference<Map<String, Object>>() {});\nconverter.convertMap(mapType, map);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Map)) {\n    throw new IllegalArgumentException(\"convertMap expects java.util.Map, got \" + value.getClass());\n}","typeGuard":"boolean isMapValue(Object value) { return value instanceof Map; }","tryCatchPattern":"try {\n    return converter.convertMap(mapType, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Not a Map: {}\", e.getMessage());\n    return Collections.emptyMap();\n}","preventionTips":["Parse JSON strings into Map before conversion.","Wrap list-of-pairs into LinkedHashMap manually.","Check driver return types: some NoSQL drivers return custom document objects, adapt them to java.util.Map.","Validate the column SqlType is actually MAP."],"tags":["type-mismatch","map-conversion","seatunnel-api"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}