alibaba/DataX · error · IllegalArgumentException
The length is not an even number
Error message
The length is not an even number
What it means
Thrown by DESCipher.hex2byte when the input byte array has an odd number of bytes. The routine decodes a hex string (2 hex chars per byte), so odd-length input cannot be valid hex and is rejected before parsing. This utility sits under DataX's DES-based password encryption/decryption of job configs.
Source
Thrown at common/src/main/java/com/alibaba/datax/common/util/DESCipher.java:221
return decrypt(new String(src));
}
public static String byte2hex(byte[] b) {
String hs = "";
String stmp = "";
for (int n = 0; n < b.length; n++) {
stmp = (Integer.toHexString(b[n] & 0XFF));
if (stmp.length() == 1)
hs = hs + "0" + stmp;
else
hs = hs + stmp;
}
return hs.toUpperCase();
}
public static byte[] hex2byte(byte[] b) {
if ((b.length % 2) != 0)
throw new IllegalArgumentException("The length is not an even number");
byte[] b2 = new byte[b.length / 2];
for (int n = 0; n < b.length; n += 2) {
String item = new String(b, n, 2);
b2[n / 2] = (byte) Integer.parseInt(item, 16);
}
return b2;
}
}
View on GitHub (pinned to 80ec23d5c5)
Solutions
- Re-copy the full ciphertext into the config without truncation (even number of hex chars)
- If a leading zero was stripped, re-encrypt the password to regenerate a clean ciphertext
- Ensure the value is produced by the matching encrypt tool/version of DESCipher
Example fix
// before password: "E4F1A" // odd length -> IllegalArgumentException // after password: "E4F1A0" // or re-encrypt to get a fresh, complete ciphertext
Defensive patterns
Strategy: validation
Validate before calling
boolean isEvenLengthHex(String s) {
return s != null && (s.length() % 2 == 0) && s.matches("(?i)[0-9a-f]+");
} Try / catch
catch (IllegalArgumentException e) {
if ("The length is not an even number".equals(e.getMessage())) {
// ciphertext corrupted/truncated: re-encrypt the password and replace it
}
throw e;
} Prevention
- Copy encrypted values with a single paste action; avoid shell re-quoting that can drop chars
- Hex-validate ciphertext before decryption
- Regenerate via the encrypt tool when in doubt
When it happens
Trigger: Passing a hex string of odd length to hex2byte — e.g. a truncated ciphertext ('ABC' instead of 'ABCD'), a string with a stripped leading zero, or non-hex data that coincidentally lost a character.
Common situations: Encrypted password in the job config was truncated by copy-paste or shell quoting; the leading zero of a byte pair was dropped somewhere in transport; decrypting data that was never hex-encoded by this cipher.
Related errors
- 您提供的配置文件有误. 路径[%s]需要配置Json格式的Map对象,但该节点发现实际类型是[%s]. 请检查您的配置并
- 您提供的配置文件有误. 路径[%s]值为null,datax无法识别该配置. 请检查您的配置并作出修改.
- 您提供的作业配置有误, List不能为空.
- dx_pad first para(%s) support l or r
- TRANSFORMER_ILLEGAL_PARAMETER
AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14).
Data as JSON: /api/errors/19c6ea9a4653c3df.
Report an issue: GitHub.