apache/flink · error · IllegalArgumentException

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

Error message

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

What it means

MemorySize.parseBytes throws IllegalArgumentException ('cannot be re represented as 64bit number of bytes (numeric overflow)') when value * unitMultiplier overflows a long. The numeric part parses fine, but applying the unit (e.g. 10000000 tb) wraps around; the overflow is detected by the round-trip check result / multiplier != value.

Source

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

            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;
    }

    private static Optional<MemoryUnit> parseUnit(String unit) {
        if (matchesAny(unit, BYTES)) {
            return Optional.of(BYTES);
        } else if (matchesAny(unit, KILO_BYTES)) {
            return Optional.of(KILO_BYTES);
        } else if (matchesAny(unit, MEGA_BYTES)) {
            return Optional.of(MEGA_BYTES);
        } else if (matchesAny(unit, GIGA_BYTES)) {
            return Optional.of(GIGA_BYTES);
        } else if (matchesAny(unit, TERA_BYTES)) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Verify the unit matches the intended magnitude — human-scale memory values should use mb/gb
  2. Pre-check: value must be <= Long.MAX_VALUE / multiplier for the chosen unit
  3. Fix the source of the oversized number rather than downgrading the unit to mask it

Example fix

# before
size: 10000000tb  # numeric overflow when multiplied

# after
size: 10000000mb  # or whatever magnitude was actually intended
Defensive patterns

Strategy: validation

Validate before calling

// ensure value * unitMultiplier <= Long.MAX_VALUE
if (value > Long.MAX_VALUE / multiplier) {
    throw new IllegalArgumentException("value " + raw + " overflows byte range after unit applied");
}
long bytes = MemorySize.parseBytes(raw);

Try / catch

catch (IllegalArgumentException e) { /* number*unit overflow — verify the unit matches the intended magnitude */ }

Prevention

When it happens

Trigger: parseBytes("10000000tb") — 10 million terabytes exceeds Long.MAX_VALUE bytes; any large number combined with a large unit (gb/tb) whose product exceeds ~9.2 exabytes.

Common situations: Mentally swapping units (entering a mebi-byte figure as terabytes); copy-paste of the wrong magnitude into memory config; automated tools composing number+unit without range checks.

Related errors


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