alibaba/DataX · error · IllegalArgumentException

根据字符串进行切分时仅支持 ASCII 字符串,而字符串:[%s]非 ASCII 字符串.

Error message

根据字符串进行切分时仅支持 ASCII 字符串,而字符串:[%s]非 ASCII 字符串.

What it means

stringToBigInteger only supports ASCII: any character with code >= 128 triggers IllegalArgumentException. String splitting works by treating each char as a digit (value = char code) in base `radix`; non-ASCII characters break this positional encoding, so the utility rejects them explicitly, echoing the offending string.

Source

Thrown at common/src/main/java/com/alibaba/datax/common/util/RangeSplitUtil.java:121

     * 由于只支持 ascii 码对应字符,所以radix 范围为[1,128]
     */
    public static BigInteger stringToBigInteger(String aString, int radix) {
        if (null == aString) {
            throw new IllegalArgumentException("参数 bigInteger 不能为空.");
        }

        checkIfBetweenRange(radix, 1, 128);

        BigInteger result = BigInteger.ZERO;
        BigInteger radixBigInteger = BigInteger.valueOf(radix);

        int tempChar;
        int k = 0;

        for (int i = aString.length() - 1; i >= 0; i--) {
            tempChar = aString.charAt(i);
            if (tempChar >= 128) {
                throw new IllegalArgumentException(String.format("根据字符串进行切分时仅支持 ASCII 字符串,而字符串:[%s]非 ASCII 字符串.", aString));
            }
            result = result.add(BigInteger.valueOf(tempChar).multiply(radixBigInteger.pow(k)));
            k++;
        }

        return result;
    }

    /**
     * 把BigInteger 转换为 String.注意:radix 和 basic 范围都为[1,128], radix + basic 的范围也必须在[1,128].
     */
    private static String bigIntegerToString(BigInteger bigInteger, int radix) {
        if (null == bigInteger) {
            throw new IllegalArgumentException("参数 bigInteger 不能为空.");
        }

        checkIfBetweenRange(radix, 1, 128);

View on GitHub (pinned to 80ec23d5c5)

Solutions

  1. Choose a splitPk column restricted to ASCII (ids, codes, hashes like MD5).
  2. If the column may contain non-ASCII, remove splitPk so the table is not split (single channel) or split on another key.
  3. Pre-validate with a regex such as ^\x00-\x7F]+$ before attempting a string split.

Example fix

// before
BigInteger v = RangeSplitUtil.stringToBigInteger(splitPkValue, RADIX);

// after
if (!splitPkValue.matches("[\u0000-]*")) {
    throw DataXException.asDataXException(CommonErrorCode.CONFIG_ERROR,
        "splitPk column contains non-ASCII value: " + splitPkValue);
}
BigInteger v = RangeSplitUtil.stringToBigInteger(splitPkValue, RADIX);
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern ASCII = Pattern.compile("^\u0000-\u007F]*$");
if (!ASCII.matcher(str).matches()) {
    throw new IllegalArgumentException("non-ASCII splitPk value: " + str);
}
BigInteger v = RangeSplitUtil.stringToBigInteger(str, radix);

Type guard

static boolean isPureAscii(String s) {
    if (s == null) return false;
    for (int i = 0; i < s.length(); i++) if (s.charAt(i) >= 128) return false;
    return true;
}

Prevention

When it happens

Trigger: Passing a string containing Chinese characters, emoji, or any non-ASCII byte (e.g. '订单2021', 'café') to stringToBigInteger — directly or via a string splitPk whose min/max boundaries contain non-ASCII data.

Common situations: Choosing a varchar splitPk column that stores Chinese or other multibyte text; test data seeded with unicode strings; migration jobs on multilingual tables.

Related errors


AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14). Data as JSON: /api/errors/2e735a7546c9ac95. Report an issue: GitHub.