{"record":{"id":"3a6acc7936b2deb3","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-float-3a6acc","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Float","messagePattern":"Unsupported convert (.+?) to Float","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":938,"sourceCode":"    default float convertFloat(T typeDefine, Number value) {\n        return convertFloat(value);\n    }\n\n    default float convertFloat(T typeDefine, String value) {\n        return convertFloat(value);\n    }\n\n    default float convertFloat(Object value) throws UnsupportedOperationException {\n        if (value instanceof Float) {\n            return (float) value;\n        }\n        if (value instanceof Number) {\n            return convertFloat((Number) value);\n        }\n        if (value instanceof String) {\n            return convertFloat((String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Float\");\n    }\n\n    default float convertFloat(Number value) {\n        return value.floatValue();\n    }\n\n    default float convertFloat(String value) {\n        return Float.parseFloat(value);\n    }\n\n    default long convertLong(T typeDefine, Object value) throws UnsupportedOperationException {\n        if (value instanceof Long) {\n            return (long) value;\n        }\n        if (value instanceof Number) {\n            return convertLong(typeDefine, (Number) value);\n        }","sourceCodeStart":920,"sourceCodeEnd":956,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L920-L956","documentation":"Thrown by BasicDataConverter.convertFloat(Object value) when the value is neither a Number nor a String; the typeDefine-less overload is reached when callers rely on the default conversion path. The message prints the offending value class so the developer knows which unexpected type arrived at a FLOAT conversion point.","triggerScenarios":"Invoking convertFloat(value) (or convertFloat with a null typeDefine path) with an object that is not Number/String — e.g. byte[], LocalDate, Boolean, Map or other POJO — when converting a row field to a float.","commonSituations":"Same as its typeDefine sibling: source/sink schema drift (field actually Date or binary but declared FLOAT), custom code calling the convenience overload directly with unconverted objects, or a connector emitting deserialized JSON objects into numeric columns.","solutions":["Match the value class in the message to the expected FLOAT input types (Number/String) and fix the upstream schema or field extraction","Convert the value explicitly before calling convertFloat (e.g. Boolean ? 1f : 0f, or parse String)","Override convertFloat(Object value) in a project-specific converter to add the missing class branch"],"exampleFix":"// before\nfloat f = converter.convertFloat(row.getField(0)); // throws for Boolean\n// after\nObject v = row.getField(0);\nfloat f = (v instanceof Boolean) ? ((Boolean) v ? 1f : 0f) : converter.convertFloat(v);","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(0);\nif (!(v instanceof Number) && !(v instanceof String)) {\n    throw new IllegalArgumentException(\"Value \" + v.getClass() + \" cannot be converted to float\");\n}","typeGuard":"static boolean isFloatConvertible(Object v) {\n    return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n    f = converter.convertFloat(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Cannot convert {} to float\", value.getClass());\n    f = 0f;\n}","preventionTips":["Call the typed overloads (convertFloat(Number)/convertFloat(String)) explicitly instead of the Object overload when the type is known","Test row conversion end-to-end with real source records","Avoid passing raw deserialized JSON/POJO objects into scalar converters"],"tags":["java","type-conversion","unsupported-operation"],"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"}