mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Fix/lambda incorrect size limit (#674)
* fix(http): remove 8 KB per-attribute limit on form-encoded request bodies Vert.x 4.x defaults HttpServerOptions.maxFormAttributeSize to a small value (effectively 8 KB via the Netty AbstractHttpData limit). This causes any request with Content-Type: application/x-www-form-urlencoded that carries a single attribute larger than the limit to be rejected with "Size exceed allowed maximum capacity". Two places fixed: - HttpOptionsCustomizer (new CDI bean): sets maxFormAttributeSize=-1 on the main Quarkus HTTP server so large form-encoded AWS Query Protocol requests (CloudFormation templates, EC2 UserData in base64, large IAM policies, etc.) are accepted. The overall body size is still bounded by quarkus.http.limits.max-body-size (512 MB). - RuntimeApiServer: passes HttpServerOptions with maxFormAttributeSize=-1 when creating the per-container Vert.x HTTP server. This fixes the case where the Lambda runtime posts a large synchronous response body (e.g. a 5 MB base64 payload) back to the Runtime API endpoint and the body is incorrectly decoded through the form attribute path. * fix(lambda): enforce AWS invoke payload size limits (sync 6 MB, async 1 MB) Rejects oversized invocation requests with HTTP 413 RequestTooLargeException before dispatching to the container, matching the AWS Lambda API contract. Also enforces the 6 MB sync response limit after the function returns. * test(lambda): add tests for invoke payload size limits Unit/integration tests (LambdaIntegrationTest) cover sync >6 MB and async >1 MB request rejections plus boundary-at-limit acceptance. Compat test (LambdaPayloadSizeLimitTest) uses the Java SDK to verify RequestTooLargeException is surfaced correctly, including a Docker-gated test for the 6 MB response limit. * test(lambda): add regression test for 5 MB response via RuntimeApiServer Verifies that a sync invocation returning a 5 MB body (within the 6 MB AWS limit) succeeds end-to-end. Without the maxFormAttributeSize fix on the RuntimeApiServer, the Lambda runtime's POST of the large response body was rejected by Netty's 8 KB form-attribute cap, crashing the request with "Size exceed allowed maximum capacity".
This commit is contained in:
6 files changed
+300
-1
No files matched your search
@@ -352,4 +352,67 @@ class LambdaIntegrationTest {
|
||||
.then()
|
||||
.statusCode(204);
|
||||
}
|
||||
|
||||
// ──────────────────────────── Invoke payload size limits ────────────────────────────
|
||||
|
||||
@Test
|
||||
@Order(30)
|
||||
void syncInvoke_payloadExceeds6MB_returns413() {
|
||||
byte[] oversized = new byte[6 * 1024 * 1024 + 1];
|
||||
|
||||
given()
|
||||
.contentType("application/octet-stream")
|
||||
.body(oversized)
|
||||
.when()
|
||||
.post(BASE_PATH + "/functions/hello-world/invocations")
|
||||
.then()
|
||||
.statusCode(413)
|
||||
.body("__type", equalTo("RequestTooLargeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(31)
|
||||
void syncInvoke_payloadExactly6MB_isNotRejected() {
|
||||
byte[] exactLimit = new byte[6 * 1024 * 1024];
|
||||
|
||||
given()
|
||||
.header("X-Amz-Invocation-Type", "DryRun")
|
||||
.contentType("application/octet-stream")
|
||||
.body(exactLimit)
|
||||
.when()
|
||||
.post(BASE_PATH + "/functions/hello-world/invocations")
|
||||
.then()
|
||||
.statusCode(not(413));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(32)
|
||||
void asyncInvoke_payloadExceeds1MB_returns413() {
|
||||
byte[] oversized = new byte[1 * 1024 * 1024 + 1];
|
||||
|
||||
given()
|
||||
.header("X-Amz-Invocation-Type", "Event")
|
||||
.contentType("application/octet-stream")
|
||||
.body(oversized)
|
||||
.when()
|
||||
.post(BASE_PATH + "/functions/hello-world/invocations")
|
||||
.then()
|
||||
.statusCode(413)
|
||||
.body("__type", equalTo("RequestTooLargeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(33)
|
||||
void asyncInvoke_payloadExactly1MB_isNotRejected() {
|
||||
byte[] exactLimit = new byte[1 * 1024 * 1024];
|
||||
|
||||
given()
|
||||
.header("X-Amz-Invocation-Type", "Event")
|
||||
.contentType("application/octet-stream")
|
||||
.body(exactLimit)
|
||||
.when()
|
||||
.post(BASE_PATH + "/functions/hello-world/invocations")
|
||||
.then()
|
||||
.statusCode(not(413));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user