minio-dotnet
minio-dotnet copied to clipboard
Agent impact on `ListObjectsAsync`
Environment:
Package Reference: Minio
Version 6.0.1
In depth details of the issue:
I have an strange problem with a code base. There is a private object storage behind my API, which is in common with other clients, and some devices such as cURL are not able to download files because of a back-end error (Authorization Exception).
Why a client device (maybe headers sent by the device or connection type) has such effects on a server-side request?
Demonstration of the issue:
Screencast from 2024-08-19 18-12-03.webm
Dependency Injection:
#region minio
services.AddMinio(configureClient => configureClient
.WithEndpoint(configuration.GetSection("AWS:RegionEndpoint").Value)
.WithCredentials(configuration.GetSection("AWS:Key").Value, configuration.GetSection("AWS:Secret").Value)
.WithSSL(Convert.ToBoolean(configuration.GetSection("AWS:SSL").Value))
);
#endregion
Handler:
public async Task<List<(string ObjectName, string MimeType)>> List(string directory)
{
var bucketName = configuration.GetSection("AWS:BucketName").Value;
var listObjectsArgs = new ListObjectsArgs()
.WithBucket(bucketName)
.WithPrefix(directory)
.WithRecursive(true);
var objects = new List<(string ObjectName, string MimeType)>();
var tcs = new TaskCompletionSource<List<(string ObjectName, string MimeType)>>();
var observable = minioClient.ListObjectsAsync(listObjectsArgs);
var subscription = observable.Subscribe(
onNext: item =>
{
var stat = minioClient.StatObjectAsync(new StatObjectArgs()
.WithBucket(bucketName)
.WithObject(item.Key));
stat.Wait();
objects.Add((stat.Result.ObjectName, stat.Result.ContentType));
},
onError: ex => { tcs.TrySetException(ex); },
onCompleted: () => { tcs.TrySetResult(objects); });
tcs.Task.Wait();
return tcs.Task.Result;
}
Exception trace:
Exception has occurred: CLR/System.AggregateException
Exception thrown: 'System.AggregateException' in System.Private.CoreLib.dll: 'One or more errors occurred.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception Minio.Exceptions.AuthorizationException : Exception_WasThrown
at Minio.MinioClient.ParseErrorFromContent(ResponseResult response)
at Minio.MinioClient.ParseError(ResponseResult response)
at Minio.Handlers.DefaultErrorHandler.Handle(ResponseResult response)
at Minio.RequestExtensions.HandleIfErrorResponse(IMinioClient minioClient, ResponseResult response, IEnumerable`1 handlers, DateTime startTime)
at Minio.RequestExtensions.<ExecuteTaskCoreAsync>d__3.MoveNext()
at Minio.RequestExtensions.<>c__DisplayClass2_0.<<ExecuteTaskAsync>b__0>d.MoveNext()
at Minio.MinioClient.<GetObjectListAsync>d__30.MoveNext()
at Minio.MinioClient.<>c__DisplayClass6_0.<<ListObjectsAsync>b__0>d.MoveNext()
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Market.Services.Network.ObjectStorageService.List(String directory) in /home/Projects/x/Services/Network/ObjectStorageService.cs:line 69
The Inner Exception:
Exception of type 'Minio.Exceptions.AuthorizationException' was thrown.
at Minio.MinioClient.ParseErrorFromContent(ResponseResult response)
at Minio.MinioClient.ParseError(ResponseResult response)
at Minio.Handlers.DefaultErrorHandler.Handle(ResponseResult response)
at Minio.RequestExtensions.HandleIfErrorResponse(IMinioClient minioClient, ResponseResult response, IEnumerable`1 handlers, DateTime startTime)
at Minio.RequestExtensions.ExecuteTaskCoreAsync(IMinioClient minioClient, IEnumerable`1 errorHandlers, HttpRequestMessageBuilder requestMessageBuilder, Boolean isSts, CancellationToken cancellationToken)
at Minio.RequestExtensions.<>c__DisplayClass2_0.<<ExecuteTaskAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Minio.MinioClient.GetObjectListAsync(GetObjectListArgs args, CancellationToken cancellationToken)
at Minio.MinioClient.<>c__DisplayClass6_0.<<ListObjectsAsync>b__0>d.MoveNext()
Thanks.