Repository: google/go-cloud (go)

Issue:
blob/s3blob: s3ForcePathStyle stopped working in v0.39.0
### Describe the bug

This was flagged by [goreleaser's tests][build] when dependabot opened the pr updating from v0.38 to v0.39.

[build]: https://github.com/goreleaser/goreleaser/pull/5080

I'm not sure if this is expected and just not documented, or if it is in fact a bug.

### To Reproduce

open a bucket (can be a local minio for example) using `s3ForcePathStyle`.

## Expected behavior

To work.

### Version

v0.39.0

### Additional context

Error:

```
open bucket s3://basic?endpoint=http%3A%2F%2Flocalhost%3A32812&region=us-east&s3ForcePathStyle=true: unknown query parameter "s3ForcePathStyle"
```

Also, forcing `awssdk=v1` makes it work again.


Pull request:
blob/s3blob: Allow using s3ForcePathStyle as a synonym of use_path_style, for backwards compatibility with V1
Fixes #3472.

Patch:
diff --git a/blob/s3blob/s3blob.go b/blob/s3blob/s3blob.go
index f575649b..f0ff6f09 100644
--- a/blob/s3blob/s3blob.go
+++ b/blob/s3blob/s3blob.go
@@ -135,6 +135,11 @@ const Scheme = "s3"
 //   - kmskeyid: The KMS key ID for server side encryption
 //   - accelerate: A value of "true" uses the S3 Transfer Accleration endpoints
 //
+// V2 additionally supports:
+//   - use_path_style: A value of true sets the UsePathStyle option.
+//   - s3ForcePathStyle: Same as use_path_style, for backwards compatibility with V1.
+//   - disable_https: A value of true disables HTTPS in the Endpoint options.
+//
 // For V1, see gocloud.dev/aws/ConfigFromURLParams for supported query parameters
 // for overriding the aws.Session from the URL.
 // For V2, see gocloud.dev/aws/V2ConfigFromURLParams.
@@ -150,11 +155,12 @@ type URLOpener struct {
 }
 
 const (
-	sseTypeParamKey      = "ssetype"
-	kmsKeyIdParamKey     = "kmskeyid"
-	accelerateParamKey   = "accelerate"
-	usePathStyleParamkey = "use_path_style"
-	disableHTTPSParamKey = "disable_https"
+	sseTypeParamKey            = "ssetype"
+	kmsKeyIdParamKey           = "kmskeyid"
+	accelerateParamKey         = "accelerate"
+	usePathStyleParamKey       = "use_path_style"
+	legacyUsePathStyleParamKey = "s3ForcePathStyle" // for backwards compatibility
+	disableHTTPSParamKey       = "disable_https"
 )
 
 func toServerSideEncryptionType(value string) (typesv2.ServerSideEncryption, error) {
@@ -212,15 +218,17 @@ func (o *URLOpener) OpenBucketURL(ctx context.Context, u *url.URL) (*blob.Bucket
 				o.EndpointOptions.DisableHTTPS = value
 			})
 		}
-		if usePathStyleParam := q.Get(usePathStyleParamkey); usePathStyleParam != "" {
-			q.Del(usePathStyleParamkey)
-			value, err := strconv.ParseBool(usePathStyleParam)
-			if err != nil {
-				return nil, fmt.Errorf("invalid value for %q: %v", usePathStyleParamkey, err)
+		for _, key := range []string{usePathStyleParamKey, legacyUsePathStyleParamKey} {
+			if usePathStyleParam := q.Get(key); usePathStyleParam != "" {
+				q.Del(key)
+				value, err := strconv.ParseBool(usePathStyleParam)
+				if err != nil {
+					return nil, fmt.Errorf("invalid value for %q: %v", key, err)
+				}
+				opts = append(opts, func(o *s3v2.Options) {
+					o.UsePathStyle = value
+				})
 			}
-			opts = append(opts, func(o *s3v2.Options) {
-				o.UsePathStyle = value
-			})
 		}
 
 		cfg, err := gcaws.V2ConfigFromURLParams(ctx, q)


Test patch:
diff --git a/blob/s3blob/s3blob_test.go b/blob/s3blob/s3blob_test.go
index 2639b74d..508964ab 100644
--- a/blob/s3blob/s3blob_test.go
+++ b/blob/s3blob/s3blob_test.go
@@ -484,6 +484,8 @@ func TestOpenBucketFromURL(t *testing.T) {
 		{"s3://mybucket?awssdk=v1&accelerate=true&dualstack=true", false},
 		// OK, use use_path_style
 		{"s3://mybucket?use_path_style=true", false},
+		// OK, use s3ForcePathStyle
+		{"s3://mybucket?s3ForcePathStyle=true", false},
 		// OK, use disable_https
 		{"s3://mybucket?disable_https=true", false},
 		// OK, use FIPS endpoints (v1)