pplu / aws-sdk-perl

A community AWS SDK for Perl Programmers
Other
171 stars 94 forks source link

SQS CreateQueue Attribute parameters serialized incorrectly #134

Closed Grinnz closed 7 years ago

Grinnz commented 7 years ago

The CreateQueue method of the SQS service has an 'Attributes' parameter which does not appear to be passed correctly to the API. Using this code (just for debugging):

my %attributes = (DelaySeconds => 10, MessageRetentionPeriod => 3600, VisibilityTimeout => 10);
my $call_object = $sqs->new_with_coercions('Paws::SQS::CreateQueue', QueueName => 'Paws2AttributeTest', Attributes => \%attributes);
say $sqs->prepare_request_for_call($call_object)->content;

The resulting request appears to have the following content:

Action=CreateQueue&Attribute.DelaySeconds=10&Attribute.MessageRetentionPeriod=3600&Attribute.VisibilityTimeout=10&QueueName=Paws2AttributeTest&Version=2012-11-05

So calling the API like this:

my $result = $sqs->CreateQueue(QueueName => 'Paws2AttributeTest', Attributes => \%attributes);

results in strange errors like "Unknown Attribute 10." and "Start of list element found where not expected". According to the API documentation, attributes should be passed as a numbered list with Name and Value parameters, such as the example at http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html#API_CreateQueue_Examples so this request content should look something like:

Action=CreateQueue&Attribute.1.Name=DelaySeconds&Attribute.1.Value=10&Attribute.2.Name=MessageRetentionPeriod&Attribute.2.Value=3600&Attribute.3.Name=VisibilityTimeout&Attribute.3.Value=10&QueueName=Paws2AttributeTest&Version=2012-11-05

A request in that format seems to succeed. It also looks like the same issue occurs with the SetQueueAttributes method.

pplu commented 7 years ago

Hi,

It looks like you've caught a bug! The serialization of the Attributes parameter is broken. Let me see if I can get you a quick fix (it looks very easy to fix)

pplu commented 7 years ago

Hi,

This has been fixed in 7b0e4f96a85f70ed9b87a5affd35bd5638f8b73a, which is on branch https://github.com/pplu/aws-sdk-perl/tree/fix/fixed-maps-serialization. Can you test out that this fixes your problems?

BTW: thanks for the detailed report. It helped write the test, debug and resolve faster 😃

Grinnz commented 7 years ago

The branch works great. Thanks!

Grinnz commented 7 years ago

This is fixed now in 0.29