minio / minio-dotnet

MinIO Client SDK for .NET
https://docs.min.io/docs/dotnet-client-quickstart-guide.html
Apache License 2.0
563 stars 223 forks source link

No not found exceptions are thrown while using SetObjectTagsAsync #1117

Open 1SHAGGYR1 opened 3 months ago

1SHAGGYR1 commented 3 months ago

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"?>

NoSuchKeyThe specified key does not exist.{any non existing Guid}{bucket name}/{bucket name}/{any non existing Guid}here go request and host id... ` 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` in the signature of `SetObjectTagsAsync` method. ![image](https://github.com/minio/minio-dotnet/assets/29119141/75704725-e524-40e7-8cb5-2510c208eaa9) ![image](https://github.com/minio/minio-dotnet/assets/29119141/0e34e079-3745-4421-8110-8b4716c08a18) ![image](https://github.com/minio/minio-dotnet/assets/29119141/edddf505-da1d-42ac-9d79-8ea46f305515)
1SHAGGYR1 commented 3 months ago

As a workaround for now before trying to update object tags I call StatObjectAsync first. This method correctly throws ObjectNotFoundException and it fits for me