{"record":{"id":"d7bf5b54e758b69b","repo":"alibaba/DataX","slug":"failed-to-parse-delimiter-hex-str-is-empty","errorCode":null,"errorMessage":"Failed to parse delimiter: `Hex str is empty`","messagePattern":"Failed to parse delimiter: `Hex str is empty`","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DelimiterParser.java","lineNumber":21,"sourceCode":"import com.google.common.base.Strings;\n\nimport java.io.StringWriter;\n\npublic class DelimiterParser {\n\n    private static final String HEX_STRING = \"0123456789ABCDEF\";\n\n    public static String parse(String sp, String dSp) throws RuntimeException {\n        if ( Strings.isNullOrEmpty(sp)) {\n            return dSp;\n        }\n        if (!sp.toUpperCase().startsWith(\"\\\\X\")) {\n            return sp;\n        }\n        String hexStr = sp.substring(2);\n        // check hex str\n        if (hexStr.isEmpty()) {\n            throw new RuntimeException(\"Failed to parse delimiter: `Hex str is empty`\");\n        }\n        if (hexStr.length() % 2 != 0) {\n            throw new RuntimeException(\"Failed to parse delimiter: `Hex str length error`\");\n        }\n        for (char hexChar : hexStr.toUpperCase().toCharArray()) {\n            if (HEX_STRING.indexOf(hexChar) == -1) {\n                throw new RuntimeException(\"Failed to parse delimiter: `Hex str format error`\");\n            }\n        }\n        // transform to separator\n        StringWriter writer = new StringWriter();\n        for (byte b : hexStrToBytes(hexStr)) {\n            writer.append((char) b);\n        }\n        return writer.toString();\n    }\n\n    private static byte[] hexStrToBytes(String hexStr) {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DelimiterParser.java#L3-L39","documentation":"doriswriter's DelimiterParser.parse throws this when the configured column_separator starts with \\x (case-insensitive) to declare a hex-encoded delimiter, but nothing follows the prefix — e.g. the literal string \"\\\\x\". After stripping the two-character prefix the remaining hex string is empty, which cannot encode any byte, so parsing aborts before stream load begins.","triggerScenarios":"Setting loadProps.column_separator (or line_delimiter) to exactly \"\\\\x\" or \"\\\\X\" in the doriswriter job JSON. Values that are empty or null fall back to the default delimiter instead; only the bare hex prefix triggers this specific error.","commonSituations":"Intending to use a literal backslash-x as the separator and writing \"\\\\x\" unaware of the hex mode, truncating a hex delimiter like \"\\\\x01\" down to \"\\\\x\", or escaping mistakes in JSON where the intended hex digits end up stripped.","solutions":["Complete the hex sequence: \"\\\\x01\" for SOH, \"\\\\x1f\", etc. — at least one hex byte must follow the prefix.","For a literal separator that merely starts with 'x', supply it without the backslash, or choose a different separator character.","Mind JSON escaping: in the job file write \"\\\\\\\\x01\" so Java sees \"\\\\x01\" if the value passes through another unescape layer.","Leave column_separator unset to use the writer's default delimiter."],"exampleFix":"// before\n\"loadProps\": { \"column_separator\": \"\\\\x\" }\n// after\n\"loadProps\": { \"column_separator\": \"\\\\x01\" }","handlingStrategy":"validation","validationCode":"void checkDelimiter(String sp) {\n  if (sp != null && sp.toUpperCase().startsWith(\"\\\\X\")) {\n    String hex = sp.substring(2);\n    if (hex.isEmpty()) throw new IllegalArgumentException(\"hex delimiter missing digits after \\\\x\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Unit-test delimiter parsing in a job-config validator before deployment.","Keep a table of proven delimiter values (\",\", \"\\\\t\", \"\\\\x01\") and never hand-edit hex prefixes."],"tags":["datax","doris","writer","configuration","delimiter"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}