{"record":{"id":"5fc186e9a86ce137","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-boolean","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Boolean, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to Boolean, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":1294,"sourceCode":"        return Byte.parseByte(value);\n    }\n\n    default byte convertByte(boolean value) {\n        return value ? (byte) 1 : (byte) 0;\n    }\n\n    default boolean convertBoolean(T typeDefine, Object value)\n            throws UnsupportedOperationException {\n        if (value instanceof Boolean) {\n            return (Boolean) value;\n        }\n        if (value instanceof Number) {\n            return convertBoolean(typeDefine, (Number) value);\n        }\n        if (value instanceof String) {\n            return convertBoolean(typeDefine, (String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \"\n                        + value.getClass()\n                        + \" to Boolean, typeDefine: \"\n                        + typeDefine);\n    }\n\n    default boolean convertBoolean(T typeDefine, Number value) {\n        return convertBoolean(value);\n    }\n\n    default boolean convertBoolean(T typeDefine, String value) {\n        return convertBoolean(value);\n    }\n\n    default boolean convertBoolean(Object value) throws UnsupportedOperationException {\n        if (value instanceof Boolean) {\n            return (Boolean) value;\n        }","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L1276-L1312","documentation":"BasicDataConverter.convertBoolean(Object) only knows how to convert Number and String values to Boolean. If the value is any other type (e.g. byte[], Date, or a custom object), it throws this UnsupportedOperationException naming the actual runtime class and the TypeDefine in effect.","triggerScenarios":"Calling a converter whose convertBoolean(Object, TypeDefine) default dispatch receives a value that is neither Number nor String after the instanceof checks fail.","commonSituations":"Reading from a source whose driver returns non-standard objects (e.g. a driver-specific boolean wrapper or byte array) into a connector relying on BasicDataConverter defaults.","solutions":["Check the raw class printed in the message and add or configure a converter that handles that type before conversion","Pre-normalize the value to Boolean/Number/String in your source before handing it to the converter","Implement a custom DataConverter/TypeConverter whose convertBoolean handles the offending type"],"exampleFix":"// before\nObject raw = rs.getObject(col); // returns java.util.UUID\nconverter.convertBoolean(raw, typeDefine); // throws\n// after\nObject raw = rs.getObject(col);\nObject normalized = raw instanceof UUID ? (raw != null ? 1 : 0) : raw;\nconverter.convertBoolean((Number) normalized, typeDefine);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Number) && !(value instanceof String)) {\n    throw new IllegalArgumentException(\"pre-normalize value of class \" + value.getClass());\n}","typeGuard":"boolean isBooleanConvertible(Object v) {\n    return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n    boolean b = converter.convertBoolean(value, typeDefine);\n} catch (UnsupportedOperationException e) {\n    log.warn(\"Boolean conversion failed for {}: {}\", value.getClass(), e.getMessage());\n    // normalize or use fallback\n}","preventionTips":["Normalize driver-specific objects to standard Java types before conversion","Log value.getClass() when debugging converter issues","Add unit tests covering all runtime types your source can emit"],"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-23T08:17:48.524Z"}