From 7f1b023ee5e62341205fb3bb653ade70f99deaf6 Mon Sep 17 00:00:00 2001 From: Paw565pl Date: Tue, 24 Mar 2026 16:56:12 +0100 Subject: [PATCH 1/3] fix: invalid condition --- api/src/main/java/io/minio/MinioAsyncClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/io/minio/MinioAsyncClient.java b/api/src/main/java/io/minio/MinioAsyncClient.java index 72cc5a484..dbe7d7578 100644 --- a/api/src/main/java/io/minio/MinioAsyncClient.java +++ b/api/src/main/java/io/minio/MinioAsyncClient.java @@ -890,7 +890,7 @@ public String getPresignedObjectUrl(GetPresignedObjectUrlArgs args) throws Minio } Http.QueryParameters queryParams = new Http.QueryParameters(); - if (args.versionId() == null) queryParams.put("versionId", args.versionId()); + if (args.versionId() != null) queryParams.put("versionId", args.versionId()); Credentials credentials = provider == null ? null : provider.fetch(); if (credentials != null && credentials.sessionToken() != null) { From 0fe755cf58d7ef67d6e3d19d705679c25b52d83a Mon Sep 17 00:00:00 2001 From: Paw565pl Date: Tue, 24 Mar 2026 19:05:00 +0100 Subject: [PATCH 2/3] test: cover regression with assertion --- functional/TestMinioClient.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/functional/TestMinioClient.java b/functional/TestMinioClient.java index 3741f76dd..889b19aa6 100644 --- a/functional/TestMinioClient.java +++ b/functional/TestMinioClient.java @@ -1270,6 +1270,20 @@ public void testGetPresignedObjectUrlForGet() throws Exception { .build(), expectedChecksum); + testTags = "[GET, versionId]"; + String versionId = "dummy-version"; + String urlString = + client.getPresignedObjectUrl( + GetPresignedObjectUrlArgs.builder() + .method(Http.Method.GET) + .bucket(bucketName) + .object(objectName) + .versionId(versionId) + .build()); + Assertions.assertTrue( + urlString.contains("versionId=" + versionId), + "versionId not found in the generated presigned URL"); + testTags = "[GET, expiry, query params]"; Map queryParams = new HashMap<>(); queryParams.put("response-content-type", "application/json"); From 178cfd377eb3ee9249f59f56a13607f2095e39f1 Mon Sep 17 00:00:00 2001 From: Paw565pl Date: Wed, 25 Mar 2026 15:53:01 +0100 Subject: [PATCH 3/3] refactor: parse url with okhttp --- functional/TestMinioClient.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/functional/TestMinioClient.java b/functional/TestMinioClient.java index 889b19aa6..752b03eab 100644 --- a/functional/TestMinioClient.java +++ b/functional/TestMinioClient.java @@ -126,6 +126,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import okhttp3.Headers; +import okhttp3.HttpUrl; import okhttp3.MultipartBody; import okhttp3.Request; import okhttp3.RequestBody; @@ -1280,9 +1281,12 @@ public void testGetPresignedObjectUrlForGet() throws Exception { .object(objectName) .versionId(versionId) .build()); - Assertions.assertTrue( - urlString.contains("versionId=" + versionId), - "versionId not found in the generated presigned URL"); + HttpUrl url = HttpUrl.parse(urlString); + Assertions.assertNotNull(url, "generated url is not valid"); + Assertions.assertEquals( + versionId, + url.queryParameter("versionId"), + "versionId query param does not match the expected value"); testTags = "[GET, expiry, query params]"; Map queryParams = new HashMap<>();