minio/minio-dotnet

No not found exceptions are thrown while using SetObjectTagsAsync

1SHAGGYR1 opened this issue · 1 comments

I'm trying to use SetObjectTagsAsync method to update tags on object in my minio bucket.
Sadly, this method doesn't inform if anything went wrong while doing so. As I understood while reading source, it is related to errors which are generated by 404 status code from minio.

I'm using Minio .net sdk. Package version is 6.0.3. Latest at the time of submitting an issue.

The problem is the following:
While I'm trying to update object tags, none of the errors related to 404 code throw an exception. The task, returned by SetObjectTagsAsync always finished successfully.

My example is provided below.
When calling SetObjectTagsAsync SDK calls the following method chain: SetObjectTagsAsync -> ExecuteTaskAsync -> ExecuteTaskCoreAsync. Inside ExecuteTaskCoreAsync response returns unsuccessful status code (check first screenshot below). At this example the real error was absence of the object in a bucket, so minio client return 404 code and it is correct.
But as you can see on the second screenshot my method (called by SetObjectTagsAsync) was PUT, so it doesn't go into any existing if condition branch or HandleIfErrorResponse method to throw an exception and simply returns responseResult containing error in an xml format:
<?xml version="1.0" encoding="UTF-8"?> <Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>{any non existing Guid}</Key><BucketName>{bucket name}</BucketName><Resource>/{bucket name}/{any non existing Guid}</Resource>here go request and host id... </Error>

It also would be fine for me to manually inspect the ResponseResult to check if there was some error in it, cause it is returned by both ExecuteTaskCoreAsync and ExecuteTaskAsync methods in a chain, but sadly SetObjectTagsAsync doesn't return it back to the consumer, it just return task, even though it has the response after awaiting ExecuteTaskAsync (check screenshot №3)

IMHO a quick workaround for giving a client the ability to manually determine if there was in error in his request would be changing the return value from Task to Task<ResponseResult> in the signature of SetObjectTagsAsync method.

image
image
image