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

Fix bug when commit session API endpoint returns 202 HTTP status code #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

casperbrike
Copy link

@casperbrike casperbrike commented Sep 9, 2024

Problem

Sometimes when we commit chunked uploads session Box API responds with 202 HTTP status code. In this case Box response is empty so parsed response is nil and we get an error when we try to read from parsed response:

https://github.com/casperbrike/boxr/blob/f71a97ba8f79bffb3bd3c36defb945ac17d8e081/lib/boxr/chunked_uploads.rb#L196-L198

Tech changes

  • Added a method with_retry_on_202 that yields a block (expecting that a call to Box API will passed in a block), checks response status, if it's 202 then sleeps for value specified in retry-after response header (as Box' documentation recommends): https://developer.box.com/guides/uploads/chunked/commit-session/
  • Wrapped commit chunked upload session API call into with_retry_on_202

@casperbrike casperbrike force-pushed the fix-chunked-upload-seesion-commit branch from f71a97b to e2a6c6b Compare September 9, 2024 15:24
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

Successfully merging this pull request may close these issues.

2 participants