aws / aws/aws-lambda-dotnet

Exceeded maximum allowed payload size

Đang mở
#1,815 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug low-effort module/lambda-client-lib p2 queued
Ngôn ngữ chính
C#
Star
1.7k
Fork
503
Merge trung bình
1 ngày 18 giờ
Pull request đã merge (30 ngày)
21

Mô tả

Describe the bug

Hi,

We have an ASP.NET Core Web API running, hosted in a Lambda function. The API uses Top Level Statements and the package Amazon.Lambda.AspNetCoreServer.Hosting.

The function acts as a Proxy Server which enables our API clients to access a lot of legacy SOAP services. In front of the Lambda function there is an API Gateway.

Some of the responses from the SOAP Services exceeds the Lambda response limit of 6MB. When this occurs the underlying Lambda runtime client receives an HTTP 413 error and throws an exception which crashes the whole application, because this happens during startup of the .net application.

I'm not sure if it is a bug or not. How can we handle those errors. In such cases the calling client application should also receive HTTP 413 and not 500.

Regression Issue
  • Select this option if this issue appears to be a regression.
Expected Behavior

Application doesn't crash, exception can be handled and send back to the client.

Current Behavior

When response size is greater than 6 MB, Lambda function receives an HTTP 413 error and crashes. The calling client receives a HTTP 500 error, probably because of the crashed application. The exception occurs during startup of the application:

{"errorMessage":"Exceeded maximum allowed payload size (6291556 bytes).","errorType":"RequestEntityTooLarge"}

at Amazon.Lambda.RuntimeSupport.InternalRuntimeApiClient.ResponseAsync(String awsRequestId, Stream outputStream, CancellationToken cancellationToken)
at Amazon.Lambda.RuntimeSupport.RuntimeApiClient.SendResponseAsync(String awsRequestId, Stream outputStream, CancellationToken cancellationToken)
at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken)
at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.RunAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Program.<Main>$(String[] args) in Program.cs:line 56
Reproduction Steps

n/a

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Lambda.AspNetCoreServer.Hosting 1.7.0

Targeted .NET Platform

.NET Core 8.0

Operating System and version

Docker container

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với InternalClientAdapted.cs quanh dòng 406 và lần theo exception qua LambdaBootstrap.InvokeOnceAsync và quá trình khởi động hosting ASP.NET Core được hiển thị trong stack trace. Tái hiện hoặc kiểm tra đường đi của response 6 MB đối với Amazon.Lambda.AspNetCoreServer.Hosting 1.7.0 trên .NET 8. Hoàn tất khi response quá lớn không làm startup bị crash và client gọi nhận được HTTP 413 thay vì 500.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, csharp, docker
Lĩnh vực
api, backend, cloud
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.