box / box-python-sdk

Box SDK for Python
http://opensource.box.com/box-python-sdk/
Apache License 2.0
418 stars 215 forks source link

commit in UploadSession returns a 202 instead of waiting for 201 #685

Closed isaacHuh closed 2 years ago

isaacHuh commented 2 years ago

Description of the Issue

commit in UploadSession returns a 202 when chunks have been uploaded but not processed yet. Shouldn't 202 be handled by the sdk or we'll have to poll until a 202 isn't returned anymore and a file object is expected anyways

https://github.com/box/box-python-sdk/blob/2605fd782396ad6e42bd11c10f846e771634b7a0/boxsdk/object/upload_session.py#L96

Versions Used

Python SDK: 3.0.1 Python: 3.8.8

arjankowski commented 2 years ago

Hi @isaacHuh ,

Thanks for submitting this issue! We will discuss this with the SDK team and get back to you ASAP!

@arjankowski

arjankowski commented 2 years ago

Hi @isaacHuh, our team has created a jira ticket for this issue and added it to our current sprint. So we'll start working on it soon.

Thanks again for raising this issue!

arjankowski commented 2 years ago

Hi @isaacHuh,

We believe that calling the request indefinitely until 201 is not the best solution here. Currently the request is repeated API.MAX_RETRY_ATTEMPTS which defaults to 5. If you want to retry more times, you can change that value.

In last of our PR here https://github.com/box/box-python-sdk/pull/696 we fixed some behaviour in commit method . Currently after API.MAX_RETRY_ATTEMPTS retries it will be returning None instead of throwing an exception.

So after receiving None you can simple call ChunkedUploader.resume to retry committing upload.

Is this solution meets your expectations?

lukaszsocha2 commented 2 years ago

Hi @isaacHuh, a pr with the change described by @arjankowski was merged and will be released with next release. The next release is planned this week so you may expect having it soon. :) I'm closing this issue now. If you'll need anything else, feel free to reopen it. Regards, @lukaszsocha2