From f5c6d585dd289f1f548f2f55098850f4ba21f78b Mon Sep 17 00:00:00 2001 From: Devansh Joshi Date: Fri, 21 Feb 2025 12:54:41 +0530 Subject: [PATCH] Update BucketExistsAsync to throw error on invalid creds if BucketExists called with incorrect credentials or host, it still returns true --- Minio/ApiEndpoints/BucketOperations.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Minio/ApiEndpoints/BucketOperations.cs b/Minio/ApiEndpoints/BucketOperations.cs index 3614bf58a..2cda3b0f9 100644 --- a/Minio/ApiEndpoints/BucketOperations.cs +++ b/Minio/ApiEndpoints/BucketOperations.cs @@ -80,9 +80,13 @@ public async Task BucketExistsAsync(BucketExistsArgs args, CancellationTok using var response = await this.ExecuteTaskAsync(ResponseErrorHandlers, requestMessageBuilder, cancellationToken: cancellationToken).ConfigureAwait(false); - return response is not null && - (response.Exception is null || - response.Exception.GetType() != typeof(BucketNotFoundException)); + if (response is not null && + response.Exception is null) + { + return true; + } + + throw response.Exception; } catch (InternalClientException ice) {