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

head_bucket returns ResponseMetadata without BucketRegion #4191

Closed
daeho-ro opened this issue Jul 9, 2024 · 3 comments
Closed

head_bucket returns ResponseMetadata without BucketRegion #4191

daeho-ro opened this issue Jul 9, 2024 · 3 comments
Assignees
Labels
bug This issue is a confirmed bug. p2 This is a standard priority issue response-requested Waiting on additional information or feedback. s3

Comments

@daeho-ro
Copy link

daeho-ro commented Jul 9, 2024

Describe the bug

Hello, I want to know the bucket location and so I used head_bucket for s3 client.

s3.head_bucket(Bucket='BucketName')

and I received ResponseMetadata as follows:

{'ResponseMetadata': {'RequestId': 'CQDWDY0TWKXA840Y', 'HostId': 'IBUaQ0NicjPCbuT/qaRww6HowsPrFuocTfG1TSrmO1K1zStoJTyzruB/Hd4apDCMBPJ2A7x/7HE=', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'IBUaQ0NicjPCbuT/qaRww6HowsPrFuocTfG1TSrmO1K1zStoJTyzruB/Hd4apDCMBPJ2A7x/7HE=', 'x-amz-request-id': 'CQDWDY0TWKXA840Y', 'date': 'Tue, 09 Jul 2024 06:57:44 GMT', 'x-amz-bucket-region': 'us-east-1', 'x-amz-access-point-alias': 'false', 'content-type': 'application/xml', 'server': 'AmazonS3'}, 'RetryAttempts': 0}}

You cannot find the BucketRegion key even though the response indicates the status code 200. This is only happen when I run the code on the us-east-1 region of AWS lambda.

Expected Behavior

It should somehow contains the 'BucketRegion': 'us-east-1' key and value in the response dict.

Current Behavior

It does not contain BucketRegion key.

Reproduction Steps

Simply write the code to call head_bucket method and deploy to the region us-east-1 of AWS Lambda, run the code.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

Installed on docker build, maybe latest

Environment details (OS name and version, etc.)

Docker on public.ecr.aws/lambda/python:3.11.2023.07.13.17-arm64

@daeho-ro daeho-ro added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Jul 9, 2024
@tim-finnigan tim-finnigan self-assigned this Jul 10, 2024
@tim-finnigan
Copy link
Contributor

Hi @daeho-ro thanks for reaching out. I tried to reproduce this for buckets in us-east-1 and us-west-2, but I received BucketRegion in the response for both. The head_bucket Boto3 command involves a call to the S3 HeadObject API and is returning the response from the API. If you are seeing results that are inconsistent with the documentation, then you may be using an older version of Boto3.

Which version of Boto3 are you using? The latest is 1.34.142, we recommend updating to a recent version if possible. You can find instructions on bundling a recent copy of Boto3 in Lambda here.

If still seeing the issue after updating, please share your debug logs (with sensitive info redacted) by adding boto3.set_stream_logger('') to your script.

@tim-finnigan tim-finnigan added response-requested Waiting on additional information or feedback. s3 p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jul 10, 2024
@daeho-ro
Copy link
Author

Indeed, the version is key. I have used the docker image public.ecr.aws/lambda/python:3.11.2023.07.13.17-arm64 and as you noticed that the date is not that recent. So I have changed the tag without date 3.11-arm64 and finally got correct answer.

Thanks, @tim-finnigan

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. p2 This is a standard priority issue response-requested Waiting on additional information or feedback. s3
2 participants