pitrou commented on code in PR #14601:
URL: https://github.com/apache/arrow/pull/14601#discussion_r1019444516
##########
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:
Can we factor this out somehow and reuse it in other places where there
could be a similar error?
(`HeadObject` below is an obvious candidate IMHO)
--
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]