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: include existing headers in prepare request #309

Merged
merged 5 commits into from
Mar 2, 2022

Conversation

unforced
Copy link
Contributor

@unforced unforced commented Mar 1, 2022

This is a needed change to allow us to properly set user agent from the python-storage library, for multi-chunked uploads.

@unforced unforced requested review from a team as code owners March 1, 2022 20:07
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/google-resumable-media-python API. label Mar 1, 2022
@unforced unforced requested a review from tswast March 1, 2022 20:08
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

As talked about in a Chat thread, it appears this reverts fd47338

From what I can tell, that was done purely as an optimization, so I don't see this causing any problems.

I do recommend running this patch against the GCS system tests just to be sure.

@@ -621,12 +621,11 @@ def test__prepare_request_success_with_headers(self):
new_headers = self._prepare_request_helper(headers)
assert new_headers is not headers
expected_headers = {
"cannot": "touch this",
Copy link
Member

Choose a reason for hiding this comment

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

This test is very subtle and relies on

def _prepare_request_helper(self, headers=None, checksum=None):
to pass in new headers when calling self._upload_in_flight(data, headers=headers, checksum=checksum). IIUC, the test is to prevent any regressions from future changes (super not clear by the name of the test).

What I don't understand is what changed when **self._headers is added so it can be tested. @Breathtender could add a test that validates the behavior change intended by adding **self._headers?

Copy link
Member

Choose a reason for hiding this comment

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

@Breathtender i spoke with @andrewsg and he clarified what was going on. Apologies, I misread this code block completely. "cannot": "touch this" is a bit distracting and would recommend changing it to: "keep": "must be kept".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh that's a good change lol

@@ -621,12 +621,11 @@ def test__prepare_request_success_with_headers(self):
new_headers = self._prepare_request_helper(headers)
assert new_headers is not headers
expected_headers = {
"cannot": "touch this",
Copy link
Member

Choose a reason for hiding this comment

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

@Breathtender i spoke with @andrewsg and he clarified what was going on. Apologies, I misread this code block completely. "cannot": "touch this" is a bit distracting and would recommend changing it to: "keep": "must be kept".

@dandhlee dandhlee added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 2, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 2, 2022
@unforced unforced merged commit 010680b into googleapis:main Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/google-resumable-media-python API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants