apache/hadoop · error · IllegalArgumentException

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

Error message

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

What it means

IntegerParam.Domain.parse (IntegerParam.java:71-82) converts the query-string token to an Integer with Integer.parseInt(str, radix) (radix 10 for the built-in parameters) after mapping the literal "null" or null to a null value. A NumberFormatException is rethrown as this IllegalArgumentException with the offending string, and the surrounding Param framework turns it into HTTP 400. It means the parameter looked numeric but was not a plain signed decimal integer.

Source

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

    }

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

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

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

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

View on GitHub (pinned to 2add963021)

Solutions

  1. Send a plain base-10 integer, e.g. buffersize=4096.
  2. Omit the parameter or send the literal value 'null' to let the server default apply.
  3. Convert human units at your call site: parse '4k' to 4096 before building the URL.

Example fix

# before
curl -i "http://nn:9870/webhdfs/v1/f?op=OPEN&buffersize=4k"
# after
curl -i "http://nn:9870/webhdfs/v1/f?op=OPEN&buffersize=4096"
Defensive patterns

Strategy: validation

Validate before calling

static Integer parseIntParam(String raw) {
  if (raw == null || raw.isEmpty() || "null".equals(raw)) return null;
  try { return Integer.parseInt(raw, 10); }
  catch (NumberFormatException e) { throw new IllegalArgumentException("not a base-10 integer: " + raw, e); }
}

Type guard

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

Prevention

When it happens

Trigger: ?buffersize=4k, ?buffersize=0x1000, ?buffersize=4096.0, ?buffersize= 4096 (embedded whitespace), ?buffersize=1e3; ?snapshotdiffindex=start on GETSNAPSHOTDIFFLISTING; a non-numeric value where the literal 'null' was intended.

Common situations: Human-friendly size suffixes ('4k', '1M') pasted from config examples — WebHDFS accepts plain integers only; locale-formatted numbers ('1.024'); copy-paste of empty-ish tokens like '-' or '+'.

Understand the failure class

Related errors


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