{"record":{"id":"8b7aba28dbf57dd7","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-short","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Short, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to Short, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":1191,"sourceCode":"    default int convertInt(LocalDateTime value) {\n        return (int) (value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000);\n    }\n\n    default int convertInt(LocalDate value) {\n        return (int) (value.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000);\n    }\n\n    default short convertShort(T typeDefine, Object value) throws UnsupportedOperationException {\n        if (value instanceof Short) {\n            return (short) value;\n        }\n        if (value instanceof Number) {\n            return convertShort(typeDefine, (Number) value);\n        }\n        if (value instanceof String) {\n            return convertShort(typeDefine, (String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Short, typeDefine: \" + typeDefine);\n    }\n\n    default short convertShort(T typeDefine, Number value) {\n        return convertShort(value);\n    }\n\n    default short convertShort(T typeDefine, String value) {\n        return convertShort(value);\n    }\n\n    default short convertShort(Object value) throws UnsupportedOperationException {\n        if (value instanceof Short) {\n            return (short) value;\n        }\n        if (value instanceof Number) {\n            return convertShort((Number) value);\n        }","sourceCodeStart":1173,"sourceCodeEnd":1209,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L1173-L1209","documentation":"Thrown by BasicDataConverter.convertShort(T typeDefine, Object value) when the value is neither a Number nor a String. Short conversion supports numeric widening/narrowing and string parsing; any other class is rejected with the value class and type definition in the message.","triggerScenarios":"Calling convertShort(typeDefine, value) with byte[], Boolean, LocalDate, Map or other non-numeric/non-string objects while mapping a field to a SMALLINT column.","commonSituations":"Source schema says binary/boolean but the sink expects SMALLINT; enum-like fields serialized as objects; catalog definitions that drifted from actual data types.","solutions":["Convert the value to Number or String before conversion (e.g. Boolean ? (short)1 : (short)0, or decode the byte[])","Fix the catalog/schema so the field type matches the source data (BOOLEAN, BYTES, etc. instead of SMALLINT)","Override convertShort(T typeDefine, Object value) in a custom converter for the reported class"],"exampleFix":"// before\nshort s = converter.convertShort(typeDefine, row.getField(0)); // byte[] throws\n// after\nObject v = row.getField(0);\nshort s = (v instanceof byte[])\n        ? ByteBuffer.wrap((byte[]) v).getShort()\n        : converter.convertShort(typeDefine, v);","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(0);\nif (!(v instanceof Number) && !(v instanceof String)) {\n    throw new IllegalArgumentException(\"Value \" + v.getClass() + \" is not convertible to SHORT\");\n}","typeGuard":"static boolean isShortConvertible(Object v) {\n    return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n    s = converter.convertShort(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Inconvertible value {} for SMALLINT: {}\", value, e.getMessage());\n    s = 0;\n}","preventionTips":["Decode binary fields before SMALLINT conversion","Keep catalog types aligned with source deserialization (BYTES stays BYTES)","Add type assertions in transforms feeding numeric sink columns"],"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"}