-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQS SendMessageBatch: Wrong Error When Sending Very Long Message #3026
Comments
First, note that you don't need to import However, even with it, I can't reproduce this. Replacing the queue URL with mine and I get the expected error
My go.mod
Are you running this behind a proxy? That 413 may be coming from your proxy. If you keep facing this, log the request and response you get from the HTTP client to ensure you get more information to move forward
|
Hello @Madrigal ! Noted about using Interesting. I editted my Expected ErrorSDK 2025/03/04 20:31:40 DEBUG Request
...
Content-Length: 1662976
...
SDK 2025/03/04 20:31:41 DEBUG Response
HTTP/1.1 400 Bad Request
Content-Length: 142
Connection: keep-alive
Content-Type: application/x-amz-json-1.0
Date: Wed, 05 Mar 2025 01:31:41 GMT
X-Amzn-Query-Error: AWS.SimpleQueueService.BatchRequestTooLong;Sender
X-Amzn-Requestid: b5a3d045-e072-5bd5-8ffa-b0044bce45de Unexpected ErrorSDK 2025/03/04 20:32:43 DEBUG Request
...
Content-Length: 1662977
...
SDK 2025/03/04 20:32:43 DEBUG Response
HTTP/1.1 413 Request Entity Too Large
Connection: close
Content-Length: 43
Content-Type: text; charset=utf-8
Date: Wed, 05 Mar 25 01:32:43 GMT
HTTP content length exceeded 1662976 bytes. |
Was able to reproduce this by increasing the message size on my end on your example (probably a side effect of the name of my queue) and now I get the same error. While it's true that this is indeed an unexpected error, I'm not sure it matters much at the end of the day. Both the 413 error and the 400 error mean that the message is too large for SQS to handle. Is there a specific part of your workflow that is impacted by this? |
In our codebase currently, we added a workaround so instead of just checking: var batchTooLongErr *sqstypes.BatchRequestTooLong
if errors.As(err, &batchTooLongErr) {
...
} We now have a helper functions that checks for both func isBatchTooLongErr(err error) bool {
var batchTooLongErr *sqstypes.BatchRequestTooLong
var httpResponseErr *awshttp.ResponseError
if errors.As(err, &batchTooLongErr) {
return true
} else if errors.As(err, &httpResponseErr) {
//AWS Go SDK V2 Bug - Issue: https://github.com/aws/aws-sdk-go-v2/issues/3026
llog.Info().Msgf("HTTP status code: %d", httpResponseErr.HTTPStatusCode())
return httpResponseErr.HTTPStatusCode() == http.StatusRequestEntityTooLarge
}
return false
} |
Given the workflow I posted above, we aren't "negatively" impacted by this. However, it's the idea that if the message we are sending is too long, we should expect the error Based purely on how I think the package should work, I think the 413 case should be handled in the Go SDK, and return |
Got it, thanks for explaining your workaround. Will leave this open in case other people find the same issue. Will file it as p3 on our end |
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
From the
sqs
pkg, the functionSendMessageBatch
is not returning the correct error when being passed a string message that is 1662853 characters or longer.Regression Issue
Expected Behavior
Expected the error below:
operation error SQS: SendMessageBatch, https response error StatusCode: 400, RequestID: 38cbfd37-878c-5d18-84b3-9d769e600fe5, AWS.SimpleQueueService.BatchRequestTooLong: Batch requests cannot be longer than 262144 bytes. You have sent 1662853 bytes."
Current Behavior
Current Error:
Reproduction Steps
Add in URL for SQS queue.
Possible Solution
No response
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
Compiler and Version used
go version go1.24.0 darwin/arm64
Operating System and version
15.3.1 (24D70)
The text was updated successfully, but these errors were encountered: