Skip to content
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 ReceiveMessageWithContext: SerializationError: failed to unmarshal response error #5235

Closed
ainsleyclark opened this issue Apr 22, 2024 · 5 comments
Assignees
Labels
bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@ainsleyclark
Copy link

ainsleyclark commented Apr 22, 2024

Describe the bug

When bumping aws-sdk-go from v1.47.5 to latest, a large amount of SerializationError errors are returned when using the SQS ReceiveMessageWithContext method.

Although the serialisation error is a red herring, it only returns Bad Request in the response body bytes, making it nearly impssible to debug and fine out the correct 400 response code as defined in the ReceiveMessage documentation.

I'm unsure if there has been a change with SQS but it seems an update has broken backwards compatibility.

Expected Behavior

Either:

  • Correct error response, or more information about why the error occurred such as response byes.
  • No error.

Current Behavior

An error is returned from the request, as shown below.

SerializationError: failed to unmarshal response error
status code: 400, request id: 
caused by: UnmarshalError: failed decoding error message
00000000  42 61 64 20 52 65 71 75  65 73 74                 |Bad Request|
caused by: invalid character 'B' looking for beginning of value

Reproduction Steps

in := &sqs.ReceiveMessageInput{
	QueueUrl:              aws.String("https://sqs.eu-west-1.amazonaws.com/000000000000/event-bus-test"),
	WaitTimeSeconds:       aws.Int64(20),
	MaxNumberOfMessages:   aws.Int64(int64(10)),
	MessageAttributeNames: []*string{aws.String("All")},
	VisibilityTimeout:     aws.Int64(int64(30)),
}

res, err = q.sqs.ReceiveMessageWithContext(ctx, in)

// Returns SerializationError

Possible Solution

No response

Additional Information/Context

No response

SDK version used

v1.51.25

Environment details (Version of Go (go version)? OS name and version, etc.)

go v1.22.0

@ainsleyclark ainsleyclark added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 22, 2024
@RanVaknin RanVaknin self-assigned this Apr 24, 2024
@RanVaknin RanVaknin added p1 This is a high priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Apr 24, 2024
@RanVaknin
Copy link
Contributor

Looking into this with priority.

@RanVaknin RanVaknin added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 24, 2024
@RanVaknin
Copy link
Contributor

Hi @ainsleyclark ,

Thanks for your patience. We had a major re-work done with SQS not too long ago where the service migrated their protocol from SQS query (xml based) to JSON protocol. I'm wondering if this issue might be related.

Can you enable the debug logs, inspect and share with us the raw response that is sent back from the service?
You can do that like so:

	cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"), config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody))
	if err != nil {
		panic(err)
	}

	client := sqs.NewFromConfig(cfg)

Thanks!
Ran~

@RanVaknin RanVaknin added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 24, 2024
@ainsleyclark
Copy link
Author

Hi @RanVaknin

Thanks for your reply.

Due to constraints it may be quite difficult to enable logging to inspect the response body.
However, I'm highly confident this is the issue as we are using pafortin/goaws and they don't support JSON encoding yet (updated quite some time ago).

Is there any workaround so we can continue to keep XML or is it a hard swap?

@RanVaknin RanVaknin removed the p1 This is a high priority issue label Apr 25, 2024
@RanVaknin
Copy link
Contributor

Hi @ainsleyclark ,

This is a hard swap. The Protocol is defined on the model level, so while you may be able to call the API directly with whichever wire protocol you choose, Since the SDK is defined based on the model, and the model can only have a single wire protocol defined, the SDK is scoped to that single protocol, which in this case is JSON.

The only other workaround I can think of is to downgrade the SDK but its not recommended. The solution here is to get 3rd party pafortin/goaws SQS clone to implement the new wire protocol.

Thanks,
Ran~

@RanVaknin RanVaknin closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2024
Copy link

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants