pplu / aws-sdk-perl

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

CreateInvalidation() MalformedInput - Unexpected list element termination #112

Open dnmfarrell opened 7 years ago

dnmfarrell commented 7 years ago

Not sure if this is a bug, or I am not providing the correct types to CreateInvalidation:

my $cfront = Paws->service('CloudFront', region => 'us-east-1');
my $uid    = join '-', gettimeofday();

$cfront->CreateInvalidation(
  DistributionId    => $distribution_id,
  InvalidationBatch => {
      CallerReference => $uid,
      Paths           => {
        Quantity => scalar @uploaded_objects,
        Items    => \@uploaded_objects,
      }   
  }   
); 

Stacktrace:

Trace begun at /home/dfarrell/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/Paws/Net/RestXMLResponse.pm line 43
Paws::Net::RestXMLResponse::handle_response('Paws::CloudFront=HASH(0x4196f40)', 'Paws::CloudFront::CreateInvalidation=HASH(0x4201eb8)', 400, '<?xml
 version="1.0"?>^J<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2016-08-01/"><Error><Type>Sender</Type><Code>MalformedInput</Code><Mess
age>Unexpected list element termination</Message></Error><RequestId>6d6ef269-94a9-11e6-b48c-f115dda83a04</RequestId></ErrorResponse>', 'HASH(0x35c6
b10)') called at /home/dfarrell/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/Paws/Net/Caller.pm line 40
Paws::Net::Caller::caller_to_response('Paws::Net::Caller=HASH(0x2175b48)', 'Paws::CloudFront=HASH(0x4196f40)', 'Paws::CloudFront::CreateInvalidatio
n=HASH(0x4201eb8)', 400, '<?xml version="1.0"?>^J<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2016-08-01/"><Error><Type>Sender</Type><
Code>MalformedInput</Code><Message>Unexpected list element termination</Message></Error><RequestId>6d6ef269-94a9-11e6-b48c-f115dda83a04</RequestId>
</ErrorResponse>', 'HASH(0x35c6b10)') called at /home/dfarrell/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/Paws/Net/Caller.pm line 32
Paws::Net::Caller::send_request('Paws::Net::Caller=HASH(0x2175b48)', 'Paws::CloudFront=HASH(0x4196f40)', 'Paws::CloudFront::CreateInvalidation=HASH
(0x4201eb8)') called at /home/dfarrell/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/Paws/Net/RetryCallerRole.pm line 18
Paws::Net::RetryCallerRole::do_call('Paws::Net::Caller=HASH(0x2175b48)', 'Paws::CloudFront=HASH(0x4196f40)', 'Paws::CloudFront::CreateInvalidation=
HASH(0x4201eb8)') called at /home/dfarrell/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/Paws/CloudFront.pm line 58
Paws::CloudFront::CreateInvalidation('Paws::CloudFront=HASH(0x4196f40)', 'DistributionId', 'ECFFL7U0PVO9A', 'InvalidationBatch', 'HASH(0x35dc298)'
pplu commented 7 years ago

Hi,

I've cought the bug. Paws isn't forming the XML for CloudFront correctly because it lacks some information from the model (how to transmit arrays of strings in the XML). I expect to have a patch tomorrow to correct this behaviour.

pplu commented 7 years ago

Hi, Can you test the code in https://github.com/pplu/aws-sdk-perl/tree/issue_112?. It should handle the CloudFront API requests to the server correctly. Can you confirm this? It would be great if you can create a test case with:

carton exec bin/paws_make_testcase CloudFront --region us-east-1 CreateInvalidation DistributionId XXX InvalidationBatch { CallerReference YYY Paths { Quantity 2 Items [ /object1 /object2 ] } }

committing the resulting files for inclusion in the Paws test suite.

dnmfarrell commented 7 years ago

Thank you, it works!