{"record":{"id":"4258db7f66c0e76b","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-short-4258db","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Short","messagePattern":"Unsupported convert (.+?) to Short","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":1213,"sourceCode":"    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        }\n        if (value instanceof String) {\n            return convertShort((String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Short\");\n    }\n\n    default short convertShort(Number value) {\n        return value.shortValue();\n    }\n\n    default short convertShort(String value) {\n        return Short.parseShort(value);\n    }\n\n    default byte convertByte(T typeDefine, Object value) throws UnsupportedOperationException {\n        if (value instanceof Byte) {\n            return (byte) value;\n        }\n        if (value instanceof Number) {\n            return convertByte(typeDefine, (Number) value);\n        }","sourceCodeStart":1195,"sourceCodeEnd":1231,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L1195-L1231","documentation":"Thrown by BasicDataConverter.convertShort(Object value) when the value is neither a Number nor a String. It is the typeDefine-less variant of error 106, and the message reports the unexpected class that could not be narrowed to a short.","triggerScenarios":"Calling the convertShort(Object) overload with Boolean, byte[], LocalDate or arbitrary objects while expecting a SMALLINT value.","commonSituations":"Direct use of the convenience overload in custom code; untyped Object rows from generic deserializers; schema drift between source field types and sink SMALLINT columns.","solutions":["Pre-convert the value (parse String, box Boolean to 0/1, decode byte[]) before calling convertShort","Update the catalog type to match the real data type","Override convertShort(Object) in a custom converter to handle the missing branch"],"exampleFix":"// before\nshort s = converter.convertShort(row.getField(0)); // Boolean throws\n// after\nObject v = row.getField(0);\nshort s = (v instanceof Boolean) ? ((Boolean) v ? (short) 1 : (short) 0) : converter.convertShort(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 short\");\n}","typeGuard":"static boolean isShortConvertible(Object v) {\n    return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n    s = converter.convertShort(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Cannot convert {} to short\", value.getClass());\n    s = 0;\n}","preventionTips":["Convert booleans/enums to numeric codes upstream","Prefer explicit casts over default coercion for SMALLINT columns","Test with representative source records covering all field types"],"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"}