apache/hadoop · error · IllegalArgumentException

Failed to parse "{str}" as a radix-{radix} long integer.

Error message

Failed to parse "{str}" as a radix-{radix} long integer.

What it means

LongParam.Domain.parse (LongParam.java:67-81) converts the query-string token with Long.parseLong(str, radix) (radix 10 for the built-in parameters); 'null' or a missing value maps to null. A NumberFormatException is rethrown as this IllegalArgumentException naming the bad string, and the request fails with HTTP 400. It means a long-typed WebHDFS parameter received something that is not a plain signed decimal integer.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/LongParam.java:78

    }

    Domain(final String paramName, final int radix) {
      super(paramName);
      this.radix = radix;
    }

    @Override
    public String getDomain() {
      return "<" + NULL + " | long in radix " + radix + ">";
    }

    @Override
    Long parse(final String str) {
      try {
        return NULL.equals(str) || str == null ? null: Long.parseLong(str,
          radix);
      } catch(NumberFormatException e) {
        throw new IllegalArgumentException("Failed to parse \"" + str
            + "\" as a radix-" + radix + " long integer.", e);
      }
    }

    /** Convert a Long to a String. */
    String toString(final Long n) {
      return n == null? NULL: Long.toString(n, radix);
    }
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Convert to plain integers first: blocksize=134217728 for 128 MB, epoch milliseconds for SETTIMES.
  2. Omit the parameter or send literal 'null' where the default is acceptable.
  3. Unit-test your URL builder with values like '128m' to catch unit leaks before they reach the server.

Example fix

# before
curl -i -X PUT "http://nn:9870/webhdfs/v1/f?op=CREATE&blocksize=128m"
# after
curl -i -X PUT "http://nn:9870/webhdfs/v1/f?op=CREATE&blocksize=134217728"
Defensive patterns

Strategy: validation

Validate before calling

static long toBytes(String human) {                    // '128m' -> 134217728
  Matcher m = Pattern.compile("([0-9]+)([kKmMgGtT]?)").matcher(human);
  if (!m.matches()) throw new IllegalArgumentException("bad size: " + human);
  long n = Long.parseLong(m.group(1));
  switch (m.group(2).toLowerCase()) {
    case "t": n <<= 40; break; case "g": n <<= 30; break; case "m": n <<= 20; break; case "k": n <<= 10; break;
  }
  return n;
}

Type guard

static boolean isPlainLong(String s) { return s != null && s.matches("[+-]?\\d+"); }

Prevention

When it happens

Trigger: ?op=OPEN&offset=1e6; ?op=CREATE&length=10MB; ?op=CREATE&blocksize=128m; ?op=SETTIMES&modificationtime=2026-08-22; ?op=CREATE&length=1,000.

Common situations: Pasting human-readable sizes ('128m', '10GB') from documentation or hdfs-site.xml examples — WebHDFS wants raw byte counts; timestamps given as ISO dates instead of epoch millis; thousands separators copied from spreadsheets.

Understand the failure class

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/66817657cc0d9afc. Report an issue: GitHub.