-
Notifications
You must be signed in to change notification settings - Fork 147
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
Received Message Attribute via XML is not decoded from base 64 #343
base: master
Are you sure you want to change the base?
Received Message Attribute via XML is not decoded from base 64 #343
Conversation
@@ -370,7 +372,7 @@ func TestSendMessageBatchV1_Xml_Success_including_attributes(t *testing.T) { | |||
WithFormField("Entries.1.MessageBody", messageBody2). | |||
WithFormField("Entries.1.MessageAttributes.1.Name", binaryAttributeKey). | |||
WithFormField("Entries.1.MessageAttributes.1.Value.DataType", binaryType). | |||
WithFormField("Entries.1.MessageAttributes.1.Value.BinaryValue", binaryValue). | |||
WithFormField("Entries.1.MessageAttributes.1.Value.BinaryValue", binaryValueEncodeString). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is for blobs are sent and received after being base64 encoded.
BinaryValue in XML should be base 64 encoded.
Hi @Admiral-Piett , can you please review this? This is the last piece to update our AWS SDK version... |
@kojisaikiAtSony I thought we talked about this change before a bit didn't we? Maybe I'm misremembering. It has been a while. What this change looks like it's trying to do is that if you were to send in a So what I want to know, is what chain of events or calls exactly are you having trouble with, and in a way that is GoAWS behaving differently than what AWS would do in production? Screenshots and a full list of the different endpoints you are calling, in order would be helpful. The reason I am asking, is that I just tested this on my real-life AWS account. I sent a message via an SNS Publish to a Topic which was subscribed to a queue, and then I received the message. Now, look at the picture below, that's the response my SDK got back from AWS. You can see in the We know AWS is encoding it's Binary Values on the way in and decoding them on the way out. That is happening in AWS internally, but the way I see it, that's not relevant to what GoAWS needs to do. It's the request and response contracts that I want to mimic. How we do that internally is up to us, and what I see between the 2 seems to match. The SendMessage requested values are not base64 encoded and the ReceiveMessage response values are not base64 encoded. Same. The only real difference I can see in my testing, is that if I did a Publish > RecieveMessage, and by the Subscription between my Topic and Queue has disabled Raw Delivery, then I think I am getting the attributes back in an base64 encoded state, as a part of that full message block. But I don't think that's what we're talking about here is it? That seems like a different issue to this one, and one I will need to look into more. Let me know if I am misunderstanding anything here. Let's get this issue sorted for you once and for all. |
Currently, when we test our scenario with various protocols, we get the following distortion:
With this PR, the behaviors will be simplified.
|
a450346
to
f774423
Compare
Hi @Admiral-Piett , I've expressed the above what we found in raw HTTP, not via the SDK. Does this make sense to you? |
Hi @Admiral-Piett, if you have time, could you please check the additional comments about what we want to achieve in the above? |
@kojisaikiAtSony I'm sorry, this has been on my agenda, but I have been swamped with other things. I think I understand now, I can see a similar problem in my testing, but just to make sure I understand the issue you're seeing has to do with the following flow.
Your issue is that, by the time you call I assume that is what we're talking about, and if so, I think you are right. That is indeed a bug. I don't think the proposed change is going to fix the root cause of this though. I think it's hinging on the fact that you've already base64 encoded it once to make this work, so a regular value like "BinaryValue: my-string" would still ruin it. This problem is a a by-product of the For the fix I think there are 2 options or even steps to this.
Let me know what you think, but I think step 1 will fix your issue for today. Step 2 would need to be done eventually when we open up to the possibility of getting non-strings coming in via JSON, but for usability right now, that's not a concern. Do you still want to make this change? If so, you could do 1 or the other or both. If not, I can do it, and I'll probably do them both while I'm thinking of the issue. Let me know! |
Squashed commits: [4c0cd93] change binary value type to string [f774423] fix endpoint (+1 squashed commit) Squashed commits: [a450346] fix want value (+1 squashed commit) Squashed commits: [a52b572] added base 64 deconde on publish [cfae427] fix endpoint [a450346] fix want value (+1 squashed commit) Squashed commits: [a52b572] added base 64 deconde on publish
f774423
to
36c63fb
Compare
Thank you for having time for this! You got our point correctly. And please say thank you for giving good alternatives! I like the idea and I applied "Step1. Convert This is ready to merge so please take a look 👍 |
addBytesToHash(hasher, attributeValue.BinaryValue) | ||
bytes, _ := base64.StdEncoding.DecodeString(attributeValue.BinaryValue) | ||
addBytesToHash(hasher, []byte(bytes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modification is necessary if we want to manage values stored internally as base64 encoded strings. The MD5 hash must be generated from the decoded original value.
As your commented, previously the value was managed internally as a base64 encoded string,
so it was also decoded when hashing.
https://github.com/Admiral-Piett/goaws/blob/v0.4.8/app/common/common.go#L52-#L54
Problem:
JSON requests has decoded from base 64 on JSON marshaller, but for XML, the
SetAttributesFromForm
does not have decoding step. So internal BinaryValue was still base 64 string (as binary) value.This is a part of XML protocol, but today the actual AWS SNS and the SDK for SNS is still using XML whereas SQS has already moved to SQS (#337). We have acknowledged that by our investigation and lack of JSON description on official SNS doc. This blocks tests that use SNS apis.
Fix:
Add base 64 decoding step in
SetAttributesFromForm
.