nealrichardson commented on a change in pull request #8185:
URL: https://github.com/apache/arrow/pull/8185#discussion_r487995903



##########
File path: cpp/src/arrow/filesystem/s3fs.cc
##########
@@ -271,17 +271,16 @@ Result<S3Options> S3Options::FromUri(const Uri& uri, 
std::string* out_path) {
     options.ConfigureDefaultCredentials();
   }
 
-  auto it = options_map.find("region");
-  if (it != options_map.end()) {
-    options.region = it->second;
-  }
-  it = options_map.find("scheme");
-  if (it != options_map.end()) {
-    options.scheme = it->second;
-  }
-  it = options_map.find("endpoint_override");
-  if (it != options_map.end()) {
-    options.endpoint_override = it->second;
+  for (const auto& kv : options_map) {
+    if (kv.first == "region") {
+      options.region = kv.second;
+    } else if (kv.first == "scheme") {
+      options.scheme = kv.second;
+    } else if (kv.first == "endpoint_override") {
+      options.endpoint_override = kv.second;
+    } else {
+      return Status::Invalid("Unexpected option in S3 URI: '", kv.first, "'");

Review comment:
       IIUC this would be a clearer, more helpful error message:
   
   ```suggestion
         return Status::Invalid("Unexpected query parameter in S3 URI: '", 
kv.first, "'");
   ```

##########
File path: cpp/src/arrow/filesystem/s3fs.cc
##########
@@ -271,17 +271,16 @@ Result<S3Options> S3Options::FromUri(const Uri& uri, 
std::string* out_path) {
     options.ConfigureDefaultCredentials();
   }
 
-  auto it = options_map.find("region");
-  if (it != options_map.end()) {
-    options.region = it->second;
-  }
-  it = options_map.find("scheme");
-  if (it != options_map.end()) {
-    options.scheme = it->second;
-  }
-  it = options_map.find("endpoint_override");
-  if (it != options_map.end()) {
-    options.endpoint_override = it->second;
+  for (const auto& kv : options_map) {

Review comment:
       Is it guaranteed that all of these query param values can only have safe 
characters and don't need to be URI decoded? (Related: I don't see docs for all 
of these so I don't know how to use them or what valid values for them are.)




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to