apache/flink · error · IllegalArgumentException

The value '{number}' cannot be re represented as 64bit numbe

Error message

The value '{number}' cannot be re represented as 64bit number (numeric overflow).

What it means

MemorySize.parseBytes rethrows as IllegalArgumentException with 'cannot be re represented as 64bit number (numeric overflow)' when Long.parseLong fails on the digit substring. The numeric part alone (before any unit multiplier) must fit in a signed 64-bit long; anything with 20+ digits fails here. The message text contains a known typo ('re represented').

Source

Thrown at flink-core-api/src/main/java/org/apache/flink/configuration/MemorySize.java:294

        int pos = 0;

        char current;
        while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {
            pos++;
        }

        final String number = trimmed.substring(0, pos);
        final String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);

        if (number.isEmpty()) {
            throw new NumberFormatException("text does not start with a number");
        }

        final long value;
        try {
            value = Long.parseLong(number); // this throws a NumberFormatException on overflow
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(
                    "The value '"
                            + number
                            + "' cannot be re represented as 64bit number (numeric overflow).");
        }

        final long multiplier = parseUnit(unit).map(MemoryUnit::getMultiplier).orElse(1L);
        final long result = value * multiplier;

        // check for overflow
        if (result / multiplier != value) {
            throw new IllegalArgumentException(
                    "The value '"
                            + text
                            + "' cannot be re represented as 64bit number of bytes (numeric overflow).");
        }

        return result;
    }

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Use a unit suffix to keep the numeric part small: 8tb instead of 8796093022208b is fine, but larger raw numbers are not
  2. Check the intended unit — values beyond ~8TB (Long.MAX_VALUE bytes) cannot be represented by MemorySize at all
  3. Fix the generator producing 20+ digit numbers

Example fix

# before (numeric overflow)
size: 99999999999999999999

# after
size: 100tb  # or another representable value
Defensive patterns

Strategy: validation

Validate before calling

String numPart = raw.trim().split("[^0-9]", 2)[0];
if (numPart.length() > 18) { // 19+ digits risk exceeding Long.MAX_VALUE (9.22e18)
    throw new IllegalArgumentException("Numeric part too large: " + numPart);
}
long bytes = MemorySize.parseBytes(raw);

Try / catch

catch (IllegalArgumentException e) { /* numeric overflow — check intended unit and magnitude, then fix the config value */ }

Prevention

When it happens

Trigger: parseBytes("99999999999999999999b"); a byte count copied from a calculator in the wrong scale (e.g. entering bytes instead of the intended unit).

Common situations: Users specifying absurdly large raw byte values instead of using units like tb; generated config writing full-precision values that exceed long range.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/6d472b314e01fdfd. Report an issue: GitHub.