Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

RequestTooLargeException vs RequestEntityTooLargeException #45

Closed
erjiang opened this issue Jan 15, 2020 · 9 comments
Closed

RequestTooLargeException vs RequestEntityTooLargeException #45

erjiang opened this issue Jan 15, 2020 · 9 comments
Assignees
Labels
feature-request New feature or request lambda service-api This issue pertains to the AWS API

Comments

@erjiang
Copy link

erjiang commented Jan 15, 2020

Please fill out the sections below to help us address your issue.

Version of AWS SDK for Go?

1.27.4

Version of Go (go version)?

1.13.5

What issue did you see?

I tried to filter errors coming from Invoke for "RequestTooLargeException" but I actually got the error "RequestEntityTooLarge" exception:

2020/01/15 14:51:45 Error invoking lambda function
2020/01/15 14:51:45 RequestEntityTooLargeException: Request must be smaller than 6291456 bytes for the InvokeFunction operation
        status code: 413, request id: 4f90b35e-c583-4c6e-bccb-9956291dd896

My error handling code looked like:

log.Println("Error invoking lambda function")
log.Println(err)
awsErr, ok := err.(awserr.Error)
if ok && awsErr.Code() == lambda.ErrCodeRequestTooLargeException {
	log.Fatal("Request too large") // never gets called, because the error codes do not match
}

The SDK defines lambda.ErrCodeRequestTooLargeException, but not lambda.ErrCodeRequestEntityTooLargeException. So, am I looking in the wrong place for the error code constant? What's the difference between RequestTooLargeException and RequestEntityTooLargeException? (The descriptions seem to describe the same thing.)

Workaround was just to use a string instead of referencing a constant from the package.

@jasdel
Copy link

jasdel commented Jan 16, 2020

Thanks for reaching out @erjiang. It looks like the RequestEntityTooLargeException is an error that the AWS Lambda API does not model in their API definition. The SDKs are built from these definitions and explains why you didn't see that error code in the SDK.

The best way to workaround this issue is to define a constant in your application to compare against the RequestEntityTooLargeException error code.

With that said, Creating a post on the AWS Lambda forums letting them known about the issue would be helpful.

@jasdel
Copy link

jasdel commented Jan 20, 2020

Do you have example code that is receiving this error message? This will help investigate this issue with the Lambda service team.

The RequestEntityTooLargeException exception looks to be an exception from the IoT Dataplane service, not Lambda. Is it possible the application is mistakenly using a IoT dataplane client instead of Lambda for this location the error is printed?

@erjiang
Copy link
Author

erjiang commented Jan 26, 2020

I did find the RequestEntityTooLargeException defined in the IoT files, but my code only touches lambda.

Here's my code:

// in init function:

client = lambda.New(sess, &aws.Config{Region: aws.String("us-east-1")})

	// aws go sdk lambda: https://docs.aws.amazon.com/sdk-for-go/api/service/lambda/
	result, err := client.Invoke(&lambda.InvokeInput{FunctionName: aws.String(lambdaName), Payload: payload, LogType: aws.String("Tail")})
	if err != nil {
		awsErr, ok := err.(awserr.Error)
		// this exception is triggered if user uploads a large file.
		// TODO: don't bother sending the request to lambda if it's too big? And
		// figure out an alternate way to do file uploads.
		if ok && (awsErr.Code() == "RequestEntityTooLargeException" || awsErr.Code() == "RequestTooLargeException") {
			w.WriteHeader(413)
			fmt.Fprintf(w, "Error 413: Upload too large")
		} else {
			w.WriteHeader(502)
			fmt.Fprintf(w, "Error 502: There was an error processing this request")
		}
		log.Println("Error invoking lambda function")
		log.Println(err)
		return
	}

as you can see I ended up just matching on strings, and also threw in a check against "RequestTooLargeException" in case the API changes.

@skmcgrail skmcgrail transferred this issue from aws/aws-sdk-go Mar 26, 2021
@ajredniwja ajredniwja added feature-request New feature or request service-api This issue pertains to the AWS API labels May 3, 2021
@stobrien89 stobrien89 added lambda and removed service-api This issue pertains to the AWS API labels Jul 26, 2021
@tim-finnigan tim-finnigan added service-api This issue pertains to the AWS API needs-ticket labels Jun 9, 2022
@vudh1 vudh1 self-assigned this Jun 9, 2022
@vudh1
Copy link

vudh1 commented Aug 19, 2022

P70312107

@vudh1 vudh1 assigned RanVaknin and unassigned vudh1 Sep 9, 2022
@RanVaknin RanVaknin assigned yasminetalby and unassigned RanVaknin Sep 27, 2023
@ashishdhingra
Copy link

Contacted service team for an update. Awaiting response.

@ashishdhingra
Copy link

Followed with service team again. RequestEntityTooLargeException is not modeled per Invoke API documentation and AWS model.

@ashishdhingra
Copy link

Contacted service team for an update. Awaiting response.

@ashishdhingra
Copy link

We have opened product feature request with the service team. As of now, we do not have ETA on when this would be implemented. It should be reviewed by service team along with other priority items. Since no action is required from our side (SDK), closing this issue.

Copy link

This issue is now closed.

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request New feature or request lambda service-api This issue pertains to the AWS API
Projects
None yet
Development

No branches or pull requests

9 participants