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: accept 201 Created as valid upload initiation response #125

Closed
wants to merge 2 commits into from

Conversation

lisandromc
Copy link
Contributor

@lisandromc lisandromc commented May 8, 2020

Accepts HTTP 201 Created as a valid upload initiation response

Fixes #124

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label May 8, 2020
@lisandromc
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels May 8, 2020
@frankyn frankyn added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 13, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 13, 2020
@frankyn frankyn self-requested a review May 13, 2020 20:50
Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a question before continuing.

@@ -452,7 +452,7 @@ def _process_initiate_response(self, response):
"""
_helpers.require_status_code(
response,
(http_client.OK,),
(http_client.OK, http_client.CREATED),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lisandromc, thanks again for sending this change. Could you show me an example of when this fails? At the moment a 201 isn't expected when a resumable session is initialized: https://cloud.google.com/storage/docs/performing-resumable-uploads#initiate-session

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendly ping on this question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Frank. I was so busy dealing with other stuff that I overlooked your question, sorry about that.

curl --location --request POST 'https://storage.googleapis.com/dam-staging/Ingest/Blink/Testing/Quinta%20Prueba%20de%20Lich/Photo/Palermo/20191005/dolomites.jpg?GoogleAccessId=digitalassetsmanagement%40production-backup-194719.iam.gserviceaccount.com&Expires=1590596284&Signature=kc1xIWCbHeqr100pSOtlA5GpkO1tLoWgU%2FFUyN3QwGQOOGSOwOoO1XCfqBFAdvYywpTi0QdVjIBnB77nq302o0fkzObgpPCUmCq9uWSS2z9ibkiAQdpwWlR9n4XfC1hn25GYumFjZ161ANxC2M5yrjR91jdYtFu2Z4VGFTN%2BhEl7xtYgQ8GHA%2FWSjfCCEfU%2FY0B4p8GMpiLHL3GZtOmBJvqJsuZdTIKb%2FscqctBNX75VLVw5FaWadkj8s0CyIRLM69jy00aPfNO%2BSrfcm4z7PHE6FV8yeJdewoXvJnRDgT0CZDAU7UzgPA4rhqSutcjQT0VkPrN6CHqniEMvhTWaLg%3D%3D' \
> --header 'x-goog-resumable: start' \
> --header 'x-upload-content-type: application/octet-stream' -D -
HTTP/2 201 
content-type: text/plain; charset=utf-8
x-guploader-uploadid: AAANsUm8Q-L1Oh6afXYzfU15-IxWUj4x_JvH8fXvbdCmv-fEdThwSBo4kh3nTyb-RSuyUoelAOLT94NpMy_aZ7YM89k
location: https://storage.googleapis.com/dam-staging/Ingest/Blink/Testing/Quinta%20Prueba%20de%20Lich/Photo/Palermo/20191005/dolomites.jpg?GoogleAccessId=digitalassetsmanagement%40production-backup-194719.iam.gserviceaccount.com&Expires=1590596284&Signature=kc1xIWCbHeqr100pSOtlA5GpkO1tLoWgU%2FFUyN3QwGQOOGSOwOoO1XCfqBFAdvYywpTi0QdVjIBnB77nq302o0fkzObgpPCUmCq9uWSS2z9ibkiAQdpwWlR9n4XfC1hn25GYumFjZ161ANxC2M5yrjR91jdYtFu2Z4VGFTN%2BhEl7xtYgQ8GHA%2FWSjfCCEfU%2FY0B4p8GMpiLHL3GZtOmBJvqJsuZdTIKb%2FscqctBNX75VLVw5FaWadkj8s0CyIRLM69jy00aPfNO%2BSrfcm4z7PHE6FV8yeJdewoXvJnRDgT0CZDAU7UzgPA4rhqSutcjQT0VkPrN6CHqniEMvhTWaLg%3D%3D&upload_id=AAANsUm8Q-L1Oh6afXYzfU15-IxWUj4x_JvH8fXvbdCmv-fEdThwSBo4kh3nTyb-RSuyUoelAOLT94NpMy_aZ7YM89k
content-length: 0
date: Wed, 20 May 2020 16:19:47 GMT
server: UploadServer
alt-svc: h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"

The URL for Google Storage is provided by a separate web service, so I don't have direct control over it. Anyway, the only apparent difference would seem to be the uploadType=resumable param.
I tried adding that parameter, but nothing changed. Still 201 Created.
Also, notice that repeatedly issuing an upload initiation request always yields 201, while one might assume a 201 response for the first time and a 200 for subsequent repeated requests, as it seems to be idempotent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying that. This change LGTM!

@frankyn
Copy link
Member

frankyn commented May 21, 2020

@lisandromc pending rebasing or merging master into PR and passing tests.

@frankyn frankyn added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 21, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 21, 2020
@lisandromc
Copy link
Contributor Author

@lisandromc pending rebasing or merging master into PR and passing tests.

Merged!

@frankyn frankyn added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 22, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 22, 2020
@frankyn
Copy link
Member

frankyn commented May 22, 2020

There are still test failures that need to be addressed. Could you take a look at them?

@frankyn frankyn self-requested a review May 26, 2020 15:25
@frankyn
Copy link
Member

frankyn commented May 26, 2020

@lisandromc apologies, tests needs to be updated and master must be merged again.

@tseaver tseaver changed the title Fixes #124 fix: accept '201 Created` as valid upload initiation response Jul 16, 2020
@tseaver tseaver changed the title fix: accept '201 Created` as valid upload initiation response fix: accept 201 Created as valid upload initiation response Jul 16, 2020
tseaver pushed a commit that referenced this pull request Jul 23, 2020
@frankyn frankyn closed this Jul 23, 2020
frankyn pushed a commit that referenced this pull request Jul 23, 2020
* fix: accept `201 Created` as valid upload response.

Supersedes: #125

Fixes: #124

* tests: accomodate unit test to extra argument.

Co-authored-by: Lisandro Mc Gough <lisandro78@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload initiation fails due to asserting wrong HTTP status code
4 participants