{"record":{"id":"20a50e0856735ac1","repo":"alibaba/DataX","slug":"type-type","errorCode":null,"errorMessage":"type={type}","messagePattern":"type=\\{type\\}","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"adswriter/src/main/java/com/alibaba/datax/plugin/writer/adswriter/ads/ColumnDataType.java","lineNumber":175,"sourceCode":"            case TIMESTAMP:\n                // \"java.sql.Timestamp\";\n                return Timestamp.class.getName();\n            case STRING:\n                // case STRING_IGNORECASE:\n                // case STRING_FIXED:\n            case MULTI_VALUE:\n                // \"java.lang.String\";\n                return String.class.getName();\n            case DOUBLE:\n                // \"java.lang.Double\";\n                return Double.class.getName();\n            case FLOAT:\n                // \"java.lang.Float\";\n                return Float.class.getName();\n                // case NULL:\n                // return null;\n            default:\n                throw new IllegalArgumentException(\"type=\" + type);\n        }\n    }\n\n    /**\n     * Get the data type object for the given value type.\n     * \n     * @param type the value type\n     * @return the data type object\n     */\n    public static ColumnDataType getDataType(int type) {\n        if (type < 0 || type >= TYPE_COUNT) {\n            throw new IllegalArgumentException(\"type=\" + type);\n        }\n        ColumnDataType dt = TYPES_BY_VALUE_TYPE.get(type);\n        // if (dt == null) {\n        // dt = TYPES_BY_VALUE_TYPE.get(NULL);\n        // }\n        return dt;","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/adswriter/src/main/java/com/alibaba/datax/plugin/writer/adswriter/ads/ColumnDataType.java#L157-L193","documentation":"Thrown from the default branch of the switch that maps a ColumnDataType enum constant to its boxed Java class name (e.g. DOUBLE -> java.lang.Double). If the switch is reached with a type that has no case (the NULL case is commented out in this code), the method rejects it with IllegalArgumentException('type=' + type). It signals an internal enum/switch mismatch rather than a user data error.","triggerScenarios":"Invoking the class-name lookup with a ColumnDataType value that is not one of the handled cases, e.g. a NULL type or a newly added enum constant that was never given a case in this switch; also any code path that fishes a type out of TYPES_BY_VALUE_TYPE and forwards it here.","commonSituations":"Upgrading adswriter to a version where a new ColumnDataType constant was added but this switch was not updated, or legacy code paths that produce the commented-out NULL type at runtime.","solutions":["Log or inspect the offending type value in the exception message to identify which ColumnDataType constant leaked through.","If it is NULL, re-enable the commented 'case NULL' (returning null or Void.class.getName()) and rebuild the plugin.","If it is a new constant, add an explicit case returning the correct Java class name.","Add a unit test that iterates ColumnDataType.values() through this method so any future constant fails fast in CI, not production."],"exampleFix":"// before\n// case NULL:\n// return null;\ndefault:\n    throw new IllegalArgumentException(\"type=\" + type);\n// after\ncase NULL:\n    return null;\ndefault:\n    throw new IllegalArgumentException(\"type=\" + type);","handlingStrategy":"validation","validationCode":"Set<ColumnDataType> handled = EnumSet.of(ColumnDataType.MULTI_VALUE, ColumnDataType.DOUBLE, ColumnDataType.FLOAT /*, all cases in the switch */);\nif (!handled.contains(type)) throw new IllegalArgumentException(\"unmapped type \" + type);","typeGuard":"boolean isMappedType(ColumnDataType t) {\n    return t != null && t != ColumnDataType.NULL; // NULL case is commented out in the switch\n}","tryCatchPattern":"try {\n    String cls = classNameFor(type);\n} catch (IllegalArgumentException e) {\n    // internal enum/switch mismatch: log type and rethrow as plugin defect\n    LOG.error(\"ColumnDataType not mapped to a Java class: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["Keep core and adswriter jars from the same release so enum sets stay consistent.","Add a unit test asserting every ColumnDataType constant survives the class-name switch.","Treat this exception as a plugin bug, not a data problem - do not retry with the same input."],"tags":["adswriter","enum","internal","type-mapping"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}