Skip Menu |

This queue is for tickets about the Amazon-S3 CPAN distribution.

Report information
The Basics
Id: 130759
Status: new
Priority: 0/
Queue: Amazon-S3

People
Owner: Nobody in particular
Requestors: haifeng.huang [...] dxc.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Error Reporting has bugs
Date: Mon, 21 Oct 2019 01:57:20 +0000
To: "bug-Amazon-S3 [...] rt.cpan.org" <bug-Amazon-S3 [...] rt.cpan.org>
From: "Huang, HaiFeng" <haifeng.huang [...] dxc.com>
I found a bug about the error reporting. Below is the example code: # connect my $s3 = Amazon::S3->new({ aws_access_key_id => $access_key, aws_secret_access_key => $secret_key, host => 's3.amazonaws.com', retry => 1, }); # create a bucket my $bucket = $s3->add_bucket({ bucket => 'my-new-bucket' }) or die $s3->err . ": " . $s3->errstr; When I run the code, I got below error messages: : at s3.pl line 20. I debugged the example program, and got the s3 response as below: <?xml version="1.0" encoding="UTF-8" ?> <Error> <Code>BucketAlreadyExists</Code> <Message>The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.</Message> <BucketName>my-new-bucket</BucketName> <RequestId>96A6EAD8E4C86D91</RequestId> <HostId>SO+fSb+G2ZLe/WvV9hCgL9ZZTXZiH3vgDpWBvaV+G1gCj28YfwRGd2Wtm99gx4dF4v1i83y8wqI=</HostId> </Error> I read about the code, and found that the error comes from "_remember_errors" routine: sub _remember_errors { my ($self, $src) = @_; unless (ref $src || $src =~ m/^[[:space:]]*</) { # if not xml (my $code = $src) =~ s/^[[:space:]]*\([0-9]*\).*$/$1/; $self->err($code); $self->errstr($src); return 1; } my $r = ref $src ? $src : $self->_xpc_of_content($src); if ($r->{Error}) { $self->err($r->{Error}{Code}); $self->errstr($r->{Error}{Message}); return 1; } return 0; } I printed the "$r" variable: $VAR1 = { 'HostId' => 'q7OLM+kIDZE1BPnde6ZFQ5Lhz3Bb0gyZKaVK+pHOfiMv+1lHe2aP5A4W8ZaN2+jbVRTKptr8eL4=', 'Message' => 'The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.', 'RequestId' => 'EF1CA33F69DF8453', 'Code' => 'BucketAlreadyExists', 'BucketName' => 'my-new-bucket' }; There is no Error in the "$r" reference, so below line if ($r->{Error}) { will never success. The solution I found is to modify "_xpc_of_content" subroutine: sub _xpc_of_content { return XMLin($_[1], 'SuppressEmpty' => '', 'ForceArray' => ['Contents'], 'KeepRoot' => 1); } I added the 'KeepRoot' attribute. The I run the example code again, and got the correct result: BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again. at s3.pl line 20. DXC Technology Company -- This message is transmitted to you by or on behalf of DXC Technology Company or one of its affiliates. It is intended exclusively for the addressee. The substance of this message, along with any attachments, may contain proprietary, confidential or privileged information or information that is otherwise legally exempt from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate any part of this message. If you have received this message in error, please destroy and delete all copies and notify the sender by return e-mail. Regardless of content, this e-mail shall not operate to bind DXC Technology Company or any of its affiliates to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. --.

Message body is not shown because it is too large.