{"record":{"id":"b5b489a1469795fe","repo":"alibaba/DataX","slug":"failed-to-parse-delimiter-hex-str-format-error","errorCode":null,"errorMessage":"Failed to parse delimiter: `Hex str format error`","messagePattern":"Failed to parse delimiter: `Hex str format error`","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DelimiterParser.java","lineNumber":28,"sourceCode":"\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) {\n        String upperHexStr = hexStr.toUpperCase();\n        int length = upperHexStr.length() / 2;\n        char[] hexChars = upperHexStr.toCharArray();\n        byte[] bytes = new byte[length];\n        for (int i = 0; i < length; i++) {\n            int pos = i * 2;\n            bytes[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DelimiterParser.java#L10-L46","documentation":"DelimiterParser.parse throws this when a hex-mode separator (prefix \\x) contains characters outside 0-9/A-F after uppercasing. Each character is validated against the HEX_STRING alphabet; any non-hex character (g, z, punctuation, space) aborts parsing with 'Hex str format error'.","triggerScenarios":"Values like \"\\\\xgg\", \"\\\\x0z\", or \"\\\\x0 \" in loadProps.column_separator / line_delimiter. Even-length but non-hex content reaches this check, so e.g. \"\\\\x||\" (intended ASCII pipe with a stray prefix) also triggers it.","commonSituations":"Prefixing an ordinary printable separator with \\x by mistake, mixing hex and ASCII thinking in one value, or case/typo issues like letter O written instead of zero.","solutions":["Use only hex digits after \\x: \"\\\\x7c\" encodes the pipe character '|'.","If the separator is plain ASCII, omit the \\x prefix and write it directly, e.g. \"|||\".","Verify with printf/od that the intended byte maps to the two hex digits you wrote.","Remove stray whitespace or quotes around the value in the job JSON."],"exampleFix":"// before\n\"loadProps\": { \"column_separator\": \"\\\\x||\" }\n// after\n\"loadProps\": { \"column_separator\": \"\\\\x7c\\\\x7c\" } // or simply \"||\"","handlingStrategy":"validation","validationCode":"for (char c : sp.substring(2).toUpperCase().toCharArray())\n  if (\"0123456789ABCDEF\".indexOf(c) == -1) throw new IllegalArgumentException(\"non-hex char in delimiter: \" + sp);","typeGuard":"boolean isValidHexDelimiter(String sp) { return sp.toUpperCase().startsWith(\"\\\\X\") && sp.substring(2).matches(\"[0-9A-Fa-f]+\"); }","tryCatchPattern":null,"preventionTips":["Never prefix plain-ASCII separators with \\\\x; use hex only for control bytes.","Convert desired ASCII to hex deliberately (e.g. '|' -> \\\\x7c) rather than guessing."],"tags":["datax","doris","writer","configuration","delimiter"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}