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

No not found exceptions are thrown while using SetObjectTagsAsync #1117

Open
1SHAGGYR1 opened this issue Jun 28, 2024 · 1 comment
Open

No not found exceptions are thrown while using SetObjectTagsAsync #1117

1SHAGGYR1 opened this issue Jun 28, 2024 · 1 comment

Comments

@1SHAGGYR1
Copy link

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

@1SHAGGYR1
Copy link
Author

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

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

No branches or pull requests

1 participant