milesgranger commented on code in PR #14601:
URL: https://github.com/apache/arrow/pull/14601#discussion_r1020060039
##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -2304,11 +2304,16 @@ Result<FileInfo> S3FileSystem::GetFileInfo(const
std::string& s) {
if (!outcome.IsSuccess()) {
if (!IsNotFound(outcome.GetError())) {
auto msg = "When getting information for bucket '" + path.bucket + "':
";
+
// Bucket exists, but failed to call HeadBucket, perhaps wrong region?
- ARROW_ASSIGN_OR_RAISE(auto region,
impl_->client_->GetBucketRegion(path.bucket));
- if (region != impl_->options().region) {
- msg += "Looks like the configured region is '" +
impl_->options().region +
- "' while the bucket is located in '" + region + "': ";
+ const auto headers = outcome.GetError().GetResponseHeaders();
+ const auto it = headers.find("x-amz-bucket-region");
+ if (it != headers.end()) {
+ const std::string region(it->second.begin(), it->second.end());
+ if (region != impl_->options().region) {
+ msg += "Looks like the configured region is '" +
impl_->options().region +
+ "' while the bucket is located in '" + region + "': ";
+ }
Review Comment:
Added my initial impressions on factoring it out into `ErrorToStatus` but
required callers to send in the current region as `impl_` wasn't available.
https://github.com/apache/arrow/pull/14601/commits/be3af79e1efe2d9d4c14d3ad5506eeddaef7edda
If this is okay, then I will press on finding other places which might also
want to pass in region when calling `ErrorToStatus`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]