Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BucketExistsAsync returns true even if it does not exist #1118

Open
RoyalScribblz opened this issue Jun 30, 2024 · 5 comments · May be fixed by #1120 or #1141
Open

BucketExistsAsync returns true even if it does not exist #1118

RoyalScribblz opened this issue Jun 30, 2024 · 5 comments · May be fixed by #1120 or #1141

Comments

@RoyalScribblz
Copy link

RoyalScribblz commented Jun 30, 2024

The logic for BucketExistsAsync is incorrect. All it determines is that the response Exception isn't a BucketNotFoundException. This means if you have another exception such as HttpRequestException, it responds that the bucket exists true even when it might not.

return response is not null &&
(response.Exception is null ||
response.Exception.GetType() != typeof(BucketNotFoundException));

I was getting a "The SSL connection could not be established, see inner exception." and never knew until I stepped into the lib code.

RoyalScribblz pushed a commit to RoyalScribblz/minio-dotnet that referenced this issue Jul 1, 2024
@albracko
Copy link

albracko commented Jul 12, 2024

This is not the only method that has wrong exception handling. I just lost few hours trying to figure out why BucketExistsAsync returns true, yet method ListBucketsAsync returns an object that was created with default constructor.

In my case i had wrong endpoint, but NO info about this in logs or any exception...which was harder to find out because i was testing on Gitlab CI....so had only logs available

I looked up your code, and the implementation of ExecuteTaskCoreAsync is not in-line with error handling in your API methods. All errors are basically being swallowed, leaving developers searching for a true cause why the API is not working.

@RoyalScribblz
Copy link
Author

Yes @albracko I also experienced this with putting and getting objects, I spent a while trying to figure out why I get "" response back from getting object but turns out whole time it was never even putting anything in there in the first place as there was no connection but it swallowed exception.

@rekarpcpro
Copy link

I think exception handling needs a review.

my code:

bool exists = await minioClient.BucketExistsAsync(new BucketExistsArgs().WithBucket(bucketName));

I will get true even if the minio container be down and not be accessible by any mean 🙄

@jculverwell
Copy link

Any progress on this?

@jculverwell
Copy link

Swallowing all the errors is really disappointing. I spent a whole day investigating why the Minio dotnet Client was saying it could find a bucket I couldn't see it. Thankfully I found this github issue. To find the actual issue I ended up installing the AWSSDK.S3 nuget package and using the code below. This immediately surfaced an SSL issue.

Hope you guys can get this fixed.

`using Amazon;
using Amazon.S3;

public class TestMinioAWS
{
private readonly AmazonS3Client _s3Client;

public TestMinioAWS()
{
    var endpoint = "minio.minio-tenant.svc.cluster.local";
    var accessKey = "miniouser";
    var secretKey = "xxxxxxx";

    var config = new AmazonS3Config
    {
        AuthenticationRegion = RegionEndpoint.USEast1.SystemName, // Should match the `MINIO_REGION` environment variable.
        ServiceURL = $"https://{endpoint}", 
        ForcePathStyle = true 
    };
    _s3Client = new AmazonS3Client(
        accessKey,
        secretKey,
        config
    );
}

public async Task CreateBucket(string bucketName) {

    Log.Information("Creating Buckets");
    var buckets = await _s3Client.ListBucketsAsync();
    Log.Information("Loaded Buckets");
    foreach (var bucket in buckets.Buckets)
    {
        Log.Information(bucket.BucketName);
    }
}

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants