eclipse-vertx/vert.x · error · IllegalArgumentException

maxSize must be > 0

Error message

maxSize must be > 0

What it means

QueryParamDecoderConfig.setMaxSize() requires the maximum number of decoded query parameters to be at least 1. Passing 0 or a negative value throws this IllegalArgumentException, since a decoder that accepts no parameters is invalid.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/http/QueryParamDecoderConfig.java:75

    this.charset = other.charset;
  }

  /**
   * @return the maximum number of parameters to decode
   */
  public int getMaxSize() {
    return maxSize;
  }

  /**
   * Set the maximum number of parameters to decode.
   *
   * @param maxSize the max size
   * @return a reference to this, so the API can be used fluently
   */
  public QueryParamDecoderConfig setMaxSize(int maxSize) {
    if (maxSize < 1) {
      throw new IllegalArgumentException("maxSize must be > 0");
    }
    this.maxSize = maxSize;
    return this;
  }

  /**
   * @return whether to use the semicolon char {@code ;} as a delimiter for query string parameters.
   */
  public boolean isUseSemicolonAsDelimiter() {
    return useSemicolonAsDelimiter;
  }

  /**
   * Configure whether to use the semicolon char {@code ;} as a delimiter for query string parameters.
   *
   * @param useSemicolonAsDelimiter whether to allow semicolon to be used as a delimiter or it is a an actual parameter name or value
   * @return a reference to this, so the API can be used fluently
   */

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Set maxSize to a positive integer (>= 1); choose a sane bound like 100 for security-sensitive endpoints.
  2. To disable query parsing entirely, do not install a decoder config rather than setting size 0.
  3. Clamp config-driven values to >= 1 before constructing QueryParamDecoderConfig.

Example fix

// before
new QueryParamDecoderConfig().setMaxSize(0); // intended 'disable'
// after
new QueryParamDecoderConfig().setMaxSize(100); // bounded positive limit
Defensive patterns

Strategy: validation

Validate before calling

int max = cfg.getInteger("maxSize", 100);
if (max < 1) max = 100;
QueryParamDecoderConfig qpc = new QueryParamDecoderConfig().setMaxSize(max);

Type guard

boolean validMaxSize(Integer v) { return v != null && v >= 1; }

Try / catch

try { config.setMaxSize(max); } catch (IllegalArgumentException e) { log.error("maxSize must be >= 1", e); }

Prevention

When it happens

Trigger: Calling setMaxSize(0) or a negative value when building custom query-parameter decoder configuration, e.g. trying to 'disable' query parameter parsing by setting the limit to 0.

Common situations: Hardening configs meant to limit DoS surface (many parameters) where 0 was used as 'disable'; generated config with unset/zeroed limits.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06). Data as JSON: /api/errors/5ea098d09b5ca25e. Report an issue: GitHub.