{"record":{"id":"7026c9a3107cf043","repo":"eclipse-vertx/vert.x","slug":"size-exceed-allowed-maximum-capacity","errorCode":null,"errorMessage":"Size exceed allowed maximum capacity","messagePattern":"Size exceed allowed maximum capacity","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/http/impl/NettyFileUpload.java","lineNumber":188,"sourceCode":"  @Override\n  public long length() {\n    return size;\n  }\n\n  @Override\n  public void delete() {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public long definedLength() {\n    return size;\n  }\n\n  @Override\n  public void checkSize(long newSize) throws IOException {\n    if (maxSize >= 0 && newSize > maxSize) {\n      throw new IOException(\"Size exceed allowed maximum capacity\");\n    }\n  }\n\n  @Override\n  public long getMaxSize() {\n    return maxSize;\n  }\n\n  @Override\n  public void setMaxSize(long maxSize) {\n    this.maxSize = maxSize;\n  }\n\n  @Override\n  public byte[] get() throws IOException {\n    throw new UnsupportedOperationException();\n  }\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/impl/NettyFileUpload.java#L170-L206","documentation":"NettyFileUpload.checkSize is the guard called as each chunk of a multipart/form-data file upload is accumulated in Vert.x. When the running total of upload bytes exceeds the configured maxSize (and maxSize is not negative/disabled), it throws this IOException to abort the upload before memory/disk is exhausted. The library throws it to let applications enforce upload size limits.","triggerScenarios":"A client uploads a file larger than the maxSize configured on the BodyLimitHandler / multipart upload (maxSize >= 0 && newSize > maxSize). The check fires during Attribute/FileUpload content streaming, e.g. in route.bodyHandler or multipart form parsing when a single file's size exceeds the limit.","commonSituations":"File-upload endpoints with a max upload size where users send oversized files; a limit configured too low for legitimate PDFs/videos; proxy chains that bypass a smaller upstream limit; after upgrading, limits that were previously disabled (-1) are now enforced.","solutions":["Increase the allowed upload size, e.g. via setUploadsDirectory/maxSize on the multipart config or a BodyLimitHandler with a larger limit","Set maxSize to -1 only if you truly want unlimited uploads (avoid in production)","Limit request size at the proxy/load balancer so oversized uploads are rejected before reaching Vert.x","Catch the IOException and respond 413 Payload Too Large with a clear message to the client"],"exampleFix":"// before\nrouter.route().handler(BodyHandler.create().setBodyLimit(1024 * 1024)); // 1MB, too small for uploads\n// after\nrouter.route().handler(BodyHandler.create().setBodyLimit(50L * 1024 * 1024)); // 50MB","handlingStrategy":"try-catch","validationCode":"long declaredSize = getContentLengthOrZero(request); // compare against configured maxSize before accepting the stream\nif (declaredSize > MAX_UPLOAD) { respond413(); return; }","typeGuard":null,"tryCatchPattern":"try {\n  request.bodyHandler(buffer -> { /* accumulate */ });\n} catch (IOException e) {\n  if (e.getMessage().contains(\"Size exceed\")) {\n    ctx.fail(413, e); // Payload Too Large\n  } else {\n    ctx.fail(e);\n  }\n}","preventionTips":["Configure BodyHandler.setBodyLimit / maxSize above your largest legitimate payload","Reject oversized requests early using the Content-Length header before streaming","Enforce limits also at proxies (nginx client_max_body_size) for defense in depth","Monitor 413 rates to tune the limit as user content grows"],"tags":["http","multipart","upload-limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}