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

fix(region cache): x-amz-bucket-region can be missing for s3 compatible #929

Conversation

shcheklein
Copy link
Contributor

In some cases x-amz-bucket-region. E.g. Yandex S3 returns these headers:

'server' = 'nginx'
'date' = 'Sat, 11 Jan 2025 18:24:12 GMT'
'content-type' = 'application/xml'
'connection' = 'keep-alive'
'keep-alive' = 'timeout=60'
'x-amz-request-id' = '427d58f44ef55822'

We do have a logic to disable region caching if custom endpoint of region are specified:

       for parameters in (config_kwargs, self.kwargs, init_kwargs, client_kwargs):
            for option in ("region_name", "endpoint_url"):
                if parameters.get(option):
                    self.cache_regions = False
                    break
        else:
            cache_regions = self.cache_regions

But it won't work if endpoint is specified via env var, or S3 config file (or some other complicated or even dynamic logic that boto is relying internally?). If someone has an idea how to get an efficient value for the endpoint URL - let me know.

@shcheklein
Copy link
Contributor Author

@martindurant it would be amazing if you could review this please :) People are hitting this from the DVC usage also - https://discuss.dvc.org/t/dvc-external-output-dependencies-keyerror-x-amz-bucket-region/2432

@martindurant
Copy link
Member

Sorry, I missed it. Looks perfect.

@martindurant martindurant merged commit 744d9c6 into fsspec:main Feb 13, 2025
21 checks passed
@shcheklein
Copy link
Contributor Author

@martindurant no worries, thanks!

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

Successfully merging this pull request may close these issues.

2 participants