-
Notifications
You must be signed in to change notification settings - Fork 261
Description
Hi,
I'm having the exact same issue described in #714 but my client is instantiated correctly calling the .Build() at the end. I've already tested other operations and everything is running fine, I can upload/download and list objects but I decided to implement the bucket verification just in case and i'm getting this error.
Code for the client
private const string Bucket = "BucketTestName";
private const string ContentType = "application/pdf";
private readonly MinioClient _client = new MinioClient().WithEndpoint(Url)
.WithCredentials(AccessKey, SecretKey)
.WithSSL().Build();
Code for putting an object in the bucket
public async Task Add(ArquivoMinio arquivo)
{
try
{
var argss = new BucketExistsArgs().WithBucket(Bucket);
var bucketExists = await _client.BucketExistsAsync(argss); //this line throws the exception
if (!bucketExists)
{
await CreateBucket();
}
using var dados = new MemoryStream(arquivo.Base64);
var args = new PutObjectArgs().WithBucket(Bucket).WithObject($"{arquivo.Caminho}")
.WithStreamData(dados).WithObjectSize(arquivo.Base64.Length)
.WithContentType(ContentType);
await _client.PutObjectAsync(args);
}
catch (MinioException e)
{
//ommited for brevity
}
}
Everything is running and working. Its just that BucketExistsAsync verification that throws the same error from the issue mentioned
System.NullReferenceException: Object reference not set to an instance of an object.
at Minio.MinioClient.ParseErrorFromContent(ResponseResult response) in /_/Minio/MinioClient.cs:line 608
at Minio.MinioClient.ParseError(ResponseResult response) in /_/Minio/MinioClient.cs:line 477
at Minio.MinioClient.<>c.<.ctor>b__94_0(ResponseResult response) in /_/Minio/MinioClient.cs:line 47
at Minio.MinioClient.HandleIfErrorResponse(ResponseResult response, IEnumerable`1 handlers, DateTime startTime) in /_/Minio/MinioClient.cs:line 670
at Minio.MinioClient.ExecuteTaskCoreAsync(IEnumerable`1 errorHandlers, HttpRequestMessageBuilder requestMessageBuilder, Boolean isSts, CancellationToken cancellationToken) in /_/Minio/MinioClient.cs:line 451
at Minio.BucketRegionCache.Update(MinioClient client, String bucketName) in /_/Minio/BucketRegionCache.cs:line 99
at Minio.MinioClient.GetRegion(String bucketName) in /_/Minio/MinioClient.cs:line 202
at Minio.MinioClient.CreateRequest(HttpMethod method, String bucketName, String objectName, IDictionary`2 headerMap, String contentType, ReadOnlyMemory`1 body, String resourcePath, Boolean isBucketCreationRequest) in /_/Minio/MinioClient.cs:line 291
at Minio.MinioClient.CreateRequest[T](BucketArgs`1 args) in /_/Minio/MinioClient.cs:line 232
at Minio.MinioClient.BucketExistsAsync(BucketExistsArgs args, CancellationToken cancellationToken) in /_/Minio/ApiEndpoints/BucketOperations.cs:line 67
This happens only when the Bucket doesn't exist. I tried running the code with the name of a existing bucket and it also runs fine and proceeds to put the object successfully.
I'm using MinIO version 5.0.0 and the server version is 2023-06-29T05:12:28Z