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

Bad request error when using Paws::S3::SelectObjectContent #403

Open
hakonhagland opened this issue May 4, 2021 · 0 comments
Open

Bad request error when using Paws::S3::SelectObjectContent #403

hakonhagland opened this issue May 4, 2021 · 0 comments

Comments

@hakonhagland
Copy link

According to the documentation the following script should work:

use feature qw(say);
use strict;
use warnings;
use Data::Dumper;
use Paws;
 
my $s3 = Paws->service('S3', region => 'us-east-2');
my $bucket = 'hakonhagland-second-bucket';
my $obj_content = $s3->SelectObjectContent(
    Bucket              => $bucket,
    Expression          => 'SELECT * FROM S3Object',
    ExpressionType      => 'SQL',
    InputSerialization  => {
        JSON => {
            Type => 'LINES',
        }
    },
    Key                 => 'test.json',
    OutputSerialization => {
        JSON => {}
    } );
print Dumper( $obj_content );

However, it fails (Ubuntu 21.04, perl 5.32) with:

$ p.pl
Paws::S3 is not stable / supported / entirely developed at /home/hakon/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Paws/S3.pm line 2.
Bad Request
 
Trace begun at /home/hakon/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Paws/Net/RestXMLResponse.pm line 25
Paws::Net::RestXMLResponse::process('Paws::Net::RestXMLResponse=HASH(0x55a69a6fcf80)', 'Paws::S3::SelectObjectContent=HASH(0x55a69abe9970)', 'Paws::Net::APIResponse=HASH(0x55a69ab15a08)') called at /home/hakon/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Paws/Net/Caller.pm line 46
Paws::Net::Caller::caller_to_response('Paws::Net::Caller=HASH(0x55a699e5d948)', 'Paws::S3=HASH(0x55a69a64fa60)', 'Paws::S3::SelectObjectContent=HASH(0x55a69abe9970)', 'Paws::Net::APIResponse=HASH(0x55a69ab15a08)') called at /home/hakon/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Paws/Net/RetryCallerRole.pm line 19
Paws::Net::RetryCallerRole::do_call('Paws::Net::Caller=HASH(0x55a699e5d948)', 'Paws::S3=HASH(0x55a69a64fa60)', 'Paws::S3::SelectObjectContent=HASH(0x55a69abe9970)') called at /home/hakon/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Paws/S3.pm line 521
Paws::S3::SelectObjectContent('Paws::S3=HASH(0x55a69a64fa60)', 'Bucket', 'hakonhagland-second-bucket', 'Expression', 'SELECT * FROM S3Object', 'ExpressionType', 'SQL', 'InputSerialization', 'HASH(0x55a69a621158)', 'Key', 'test.json', 'OutputSerialization', 'HASH(0x55a69a6508a0)') called at p.pl line 11

I checked the source code in Paws/Net/RestXmlCaller.pm line 237, it computes $xml_body as:

<OutputSerialization><JSON></JSON></OutputSerialization>SQL<InputSerialization><JSON><Type>LINES</Type></JSON></InputSerialization>SELECT * FROM S3Object

Notice the free text (not within XML tags) SQL and SELECT * FROM S3Object. According to the AWS documentation, the correct XML body should look like this:

<OutputSerialization><JSON></JSON></OutputSerialization><ExpressionType>SQL</ExpressionType><InputSerialization><JSON><Type>LINES</Type></JSON></InputSerialization><Expression>SELECT * FROM S3Object</Expression>

See also this question on stackoverflow.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant