why does the sdk raise an exception when an object is not found? #2513
-
I use the amazon sdk to query a minio server, but I assume that it doesn't matter if it's a amazon s3 or a minio server. When having the following code (querying a non existing object)
Why does this raise a I'm just curious about the reasoning because for me trying to get a non existent object is not something exceptional and I assume if I would create the whole http request manually in postman a 404 would be returned. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@Arikael the CCing @normj for additional inputs. |
Beta Was this translation helpful? Give feedback.
-
I have no experience with Minio server all I can assume is Minio server's emulation of S3 is not handling the object not found (404) scenario the same way S3 does. From the SDK's point of view we make the HTTP request and parse the response back as we expect S3 to do. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@Arikael the
GetObjectAsync()
invokes GetObject S3 API operation and is expected to return the existing object with the content body. The Permissions section specifies thatIf the object you request does not exist, the error Amazon S3 returns depends on whether you also have the s3:ListBucket permission
. The error is returned by the S3 service in the form of HTTP status code, either404
or403
. All AWS SDK(s) are generated from service models, for S3 the model is here and ForGetObject
it specifiesNoSuchKey
as one of the errors. this behavior is consistent across all the SDK(s) and the errors the possibly handled by throwing exceptions.CCing @normj for additional inputs.