-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
doesObjectExist should not return true or false based on assumptions #2342
Comments
Hi @maiermic, Thanks for raising this! We'll probably go the route of a |
@stobrien89 Thank you for looking into this 😃 |
What is the cost of doesObjectExist()? |
@adrianbecker013, it's the equivalent of a single HEAD request/ |
@stobrien89 I'm not sure I understood your question correctly. Regarding my private project that I mention in the issue description in Additional context:
It looks like the cause of the case I mentioned to reproduce the issue in another way:
I would not catch any of these exceptions. However, I don't think that I got a status code 403 as response in my private project. According to this table, Maybe, it helps to take a look, how they fixed it in the Java SDK. I asked for the relevant changes. |
Hi @maiermic, Sorry for the confusion. I was just asking in the off chance you had debugged this down to S3ClientTrait level. Thank you for the information! The return value for As far as the new implementation is concerned, I want to stick with |
|
Hi @maiermic, Thanks again for the feedback. The new methods have been implemented and will be available in tomorrow's release. |
@stobrien89 Thank you very much for fixing this issue 👍 |
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
If the request made in
doesObjectExist
fails for any reason, it should throw an exception instead of returningfalse
based on any assumptions (e.g. bucket does not exist if endpoint can not be reached). Otherwise, the result may be wrong, i.e.false
is returned, even though the object does actually exist.I guess it is a similar issue as in the Java SDK. You may consider to introduce
doesBucketExistV2
as wellVersion of AWS SDK for PHP?
Example: v3.191.6
Version of PHP (
php -v
)?7.4
To Reproduce (observed behavior)
To use an endpoint URL that can not be resolved, is IMO the easiest way to get an error in the request. Otherwise, it depends on your endpoint configuration. You can run the following example without any changes to the configuration:
You can also reproduce this issue with your own endpoint if you use invalid credentials to trigger a 403. In that case,
doesObjectExist
should throw an exception, too.Expected behavior
doesObjectExist
should throw an exception.Additional context
In my private project, I had an issue, when I uploaded a lot of files. I used
doesObjectExist
to check if I already uploaded the file. This case was actually meant to be used, if I have to run the script again. However, in the first run,doesObjectExist
returnedtrue
in some cases (0.1%), even though the file did actually not exist and hence, wasn't uploaded. Are there any assumptions, wheretrue
is returned? I'm not sure how to reproduce this consistently or how to log relevant information if the result was wrong, but I guess that requests have failed with another error as I described in the reproduce section of this issue.The text was updated successfully, but these errors were encountered: