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

In Ruby, S3 get_object_attributes() breaks in aws-sdk-core v3.192.0 and newer. #3032

Closed
docwhat opened this issue May 29, 2024 · 5 comments
Closed
Labels
bug This issue is a bug. investigating Issue is being investigated

Comments

@docwhat
Copy link

docwhat commented May 29, 2024

Describe the bug

When making a call to get_object_attributes() in Ruby using the aws-sdk-s3 Gem I get only partial responses.

For example:

s3_client.get_object_attributes(
  bucket: s3_bucket,
  key: input_s3_key,
  object_attributes: %w[ETag Checksum ObjectParts StorageClass ObjectSize]
)

Will return something like this:

#<struct Aws::S3::Types::GetObjectAttributesOutput delete_marker=nil, last_modified=2024-05-29 21:46:59 +0000, version_id=nil, request_charged=nil, etag="eca36cd6c16e750db2e256cee9c6daec", checksum=nil, object_parts=nil, storage_class=nil, object_size=nil>

The exact attribute(s) returned don't seem to be consistent.

Expected Behavior

I expect to get a filled-out Aws::S3::Types::GetObjectAttributesOutput object.

If I revert back to s3-aws-core version 3.191.6, it works as expected:

#<struct Aws::S3::Types::GetObjectAttributesOutput delete_marker=nil, last_modified=2024-05-29 22:05:16 +0000, version_id=nil, request_charged=nil, etag="eca36cd6c16e750db2e256cee9c6daec", checksum=nil, object_parts=nil, storage_class="STANDARD", object_size=551837>

Current Behavior

When using aws-sdk-s3 v3.192.0 or higher, I get a bogus result:

#<struct Aws::S3::Types::GetObjectAttributesOutput delete_marker=nil, last_modified=2024-05-29 21:46:59 +0000, version_id=nil, request_charged=nil, etag="eca36cd6c16e750db2e256cee9c6daec", checksum=nil, object_parts=nil, storage_class=nil, object_size=nil>

Reproduction Steps

I have been able to reproduce it using curl:

curl --url 'http://localhost:4566/test-temp/input-eca36cd6c16e750db2e256cee9c6daec-551837.pdf?attributes' -H 'X-Amz-Object-Attributes: ETag,Checksum,ObjectParts,StorageClass,ObjectSize'
<?xml version='1.0' encoding='utf-8'?>
<GetObjectAttributesOutput xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><ETag>eca36cd6c16e750db2e256cee9c6daec</ETag><StorageClass>STANDARD</StorageClass><ObjectSize>551837</ObjectSize></GetObjectAttributesOutput>
curl --url 'http://localhost:4566/test-temp/input-eca36cd6c16e750db2e256cee9c6daec-551837.pdf?attributes' -H 'X-Amz-Object-Attributes: ETag, Checksum, ObjectParts, StorageClass, ObjectSize'
<?xml version='1.0' encoding='utf-8'?>
<GetObjectAttributesOutput xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><ETag>eca36cd6c16e750db2e256cee9c6daec</ETag></GetObjectAttributesOutput>

It seems that if the X-Amz-Object-Attributes header contains spaces that the Localstack parser stops reading.

Possible Solution

The parser for the X-Amz-Object-Attributes header should be less rigid and allow spaces.

Additional Information/Context

No response

Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version

aws-sdk-core

Environment details (Version of Ruby, OS environment)

ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]

@docwhat docwhat added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 29, 2024
@docwhat
Copy link
Author

docwhat commented May 29, 2024

I apologize. I meant to put this in Localstack, not your project... though I'm confused why spaces were introduced...

@jterapin
Copy link
Contributor

Hi! Thank you very much for bringing this to our attention.

I believe the spacing was introduced when there was a large effort to keep the protocols aligned across SDKs. We will take a closer look and get back to you.

@jterapin jterapin added investigating Issue is being investigated and removed needs-triage This issue or PR still needs to be triaged. labels May 30, 2024
@jterapin
Copy link
Contributor

Given that RFC 9110 indicates that the optional white space is valid, this appears to be a localstack issue (and thank you for submitting the ticket there!). I will closing this ticket but feel free to let us know if you have any questiuons.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@docwhat
Copy link
Author

docwhat commented May 30, 2024

Thanks for looking, @jterapin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. investigating Issue is being investigated
Projects
None yet
Development

No branches or pull requests

2 participants