Skip to content

fix(lifecycle): raise axum body limit to 6 MB for large Lambda payloads#1044

Open
litianningdatadog wants to merge 2 commits intomainfrom
tianning.li/SVLS-8609
Open

fix(lifecycle): raise axum body limit to 6 MB for large Lambda payloads#1044
litianningdatadog wants to merge 2 commits intomainfrom
tianning.li/SVLS-8609

Conversation

@litianningdatadog
Copy link
Contributor

@litianningdatadog litianningdatadog commented Feb 24, 2026

https://datadoghq.atlassian.net/browse/SVLS-8609
Issue reported: #1041

Summary

  • axum 0.7+ applies a 2 MB default body limit globally; the /lambda/start-invocation endpoint was rejecting payloads larger than 2 MB with length limit exceeded
  • Raises the limit to 6 MB (DefaultBodyLimit::max(6 * 1024 * 1024)) to match Lambda's maximum synchronous invocation payload size
  • Adds three unit tests covering: accept above the old 2 MB default, accept at boundary (6 MB − 1 byte), reject above 6 MB (413)

Test plan

  • Unit tests
  • Run bash local_tests/repro-large-payload.sh which sets up the local test env and sends a 3 MB payload to /lambda/start-invocation and verifies HTTP 200 with no length limit exceeded error
Scenario Log
Without the fix {"level":"ERROR","message":"DD_EXTENSION | ERROR | Failed to extract request body: Failed to buffer the request body: length limit exceeded"}
With the fix {"level":"DEBUG","message":"DD_EXTENSION | DEBUG | Received start invocation request from headers:{\"datadog-meta-lang\": \"java\", \"user-agent\": \"curl/8.3.0\", \"host\": \"localhost:8124\", \"lambda-runtime-aws-request-id\": \"test-large-payload-request\", \"expect\": \"100-continue\", \"accept\": \"*/*\", \"content-length\": \"3200074\", \"content-type\": \"application/json\"}"}

axum 0.7+ applies a 2 MB default body limit globally, causing the
/lambda/start-invocation endpoint to reject payloads larger than 2 MB
with "length limit exceeded". Raises the limit to 6 MB to match
Lambda's maximum synchronous invocation payload size.

Fixes #1041
Comment on lines +40 to +42
// Lambda's maximum synchronous invocation payload size
// reference: https://docs.aws.amazon.com/lambda/latest/api/API_Invoke.html
const LAMBDA_INVOCATION_MAX_PAYLOAD: usize = 6 * 1024 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering how would this look like with streaming lambda payload... do we have guards to not send the payload if it goes over the limit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in streaming the max is 200MB

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean good for now, but we might want to leave a comment about streaming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants