bkietz commented on code in PR #41798:
URL: https://github.com/apache/arrow/pull/41798#discussion_r1613704875


##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -601,44 +601,81 @@ class S3Client : public Aws::S3::S3Client {
  public:
   using Aws::S3::S3Client::S3Client;
 
+  static inline constexpr auto kBucketRegionHeaderName = "x-amz-bucket-region";
+
+  std::string GetBucketRegionFromHeaders(
+      const Aws::Http::HeaderValueCollection& headers) {
+    const auto it = headers.find(ToAwsString(kBucketRegionHeaderName));
+    if (it != headers.end()) {
+      return std::string(FromAwsString(it->second));
+    }
+    return std::string();

Review Comment:
   It seems slightly suspicious that we're not returning an error in this case
   ```suggestion
       return Status::IOError("When resolving region for bucket '", 
request.GetBucket(),
                              "': missing 'x-amz-bucket-region' header in 
response");
   ```
   
   I think this would be less surprising, and below where we need an IOError we 
could write
   ```c++
     template <typename ErrorType>
     Result<std::string> GetBucketRegionFromError(
         const std::string& bucket, const Aws::Client::AWSError<ErrorType>& 
error) {
       Result<std::string> region = 
GetBucketRegionFromHeaders(error.GetResponseHeaders());
       if (!region.ok() && error.GetResponseCode() == 
Aws::Http::HttpResponseCode::NOT_FOUND) {
         return Status::IOError("Bucket '", bucket, "' not found");
       }
       return region;
     }
   ```



-- 
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]

Reply via email to