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

_next method creates a HTTP request with wrong content-length header #1403

Closed
schweikert opened this issue Jun 7, 2021 · 0 comments
Closed

_next method creates a HTTP request with wrong content-length header #1403

schweikert opened this issue Jun 7, 2021 · 0 comments

Comments

@schweikert
Copy link
Contributor

@schweikert schweikert commented Jun 7, 2021

Using google-api-python-client 2.2.0 and the GCP monitoring API, I received an error when retrieving the second page of a projects.timeSeries.query call:

can't fetch data, reason: Invalid JSON payload received. Unexpected end of string. Expected an object key or }.

Turns out that the content-length header is wrong and doesn't match with the body with the additional pageToken field.

The problem is in https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/discovery.py#L1285: the body is replaced, but the content-length stays the same because it is only updated at Request object creation time. I will prepare a PR for this.

schweikert added a commit to schweikert/google-api-python-client that referenced this issue Jun 7, 2021
schweikert added a commit to schweikert/google-api-python-client that referenced this issue Jun 7, 2021
The content-length header only gets updated at request object
initialization, so make sure we update it here after we modified the
body.

Fixes googleapis#1403
schweikert added a commit to schweikert/google-api-python-client that referenced this issue Jun 7, 2021
The content-length header only gets updated at request object
initialization, so make sure we update it here after we modified the
body.

Fixes googleapis#1403
schweikert added a commit to schweikert/google-api-python-client that referenced this issue Jun 8, 2021
The content-length header only gets updated at request object
initialization, so make sure we update it here after we modified the
body.

Fixes googleapis#1403
schweikert added a commit to schweikert/google-api-python-client that referenced this issue Jun 8, 2021
The content-length header only gets updated at request object
initialization, so make sure we update it here after we modified the
body.

Fixes googleapis#1403
schweikert added a commit to schweikert/google-api-python-client that referenced this issue Jun 8, 2021
The content-length header only gets updated at request object
initialization, so make sure we update it here after we modified the
body.

Fixes googleapis#1403
busunkim96 pushed a commit that referenced this issue Jun 8, 2021
The content-length header only gets updated at request object
initialization, so make sure we update it here after we modified the
body.

Fixes #1403

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
gcf-merge-on-green bot pushed a commit that referenced this issue Jun 14, 2021
🤖 I have created a release \*beep\* \*boop\*
---
## [2.9.0](https://www.github.com/googleapis/google-api-python-client/compare/v2.8.0...v2.9.0) (2021-06-12)


### Features

* **analyticsadmin:** update the api 3ed7887 ([33237a8](https://www.github.com/googleapis/google-api-python-client/commit/33237a8250e3becfaa1e4b5f67ef0c887cfc44a9))
* **analyticsadmin:** update the api a715d2b ([0f0918f](https://www.github.com/googleapis/google-api-python-client/commit/0f0918f92a699753b52c77dd236ad84ee00a32a7))
* **apigee:** update the api 9fcf80b ([0f0918f](https://www.github.com/googleapis/google-api-python-client/commit/0f0918f92a699753b52c77dd236ad84ee00a32a7))
* **appengine:** update the api ffcf860 ([26aa9e2](https://www.github.com/googleapis/google-api-python-client/commit/26aa9e282e30ca9c8797ee5346cbe9c0b9ca65a7))
* **chat:** update the api 47ff8a5 ([0f0918f](https://www.github.com/googleapis/google-api-python-client/commit/0f0918f92a699753b52c77dd236ad84ee00a32a7))
* **composer:** update the api 4862529 ([33237a8](https://www.github.com/googleapis/google-api-python-client/commit/33237a8250e3becfaa1e4b5f67ef0c887cfc44a9))
* **containeranalysis:** update the api 9a1c70b ([26aa9e2](https://www.github.com/googleapis/google-api-python-client/commit/26aa9e282e30ca9c8797ee5346cbe9c0b9ca65a7))
* **documentai:** update the api 07a6e77 ([26aa9e2](https://www.github.com/googleapis/google-api-python-client/commit/26aa9e282e30ca9c8797ee5346cbe9c0b9ca65a7))
* **drive:** update the api 773910f ([26aa9e2](https://www.github.com/googleapis/google-api-python-client/commit/26aa9e282e30ca9c8797ee5346cbe9c0b9ca65a7))
* **genomics:** update the api 8a1c8a6 ([33237a8](https://www.github.com/googleapis/google-api-python-client/commit/33237a8250e3becfaa1e4b5f67ef0c887cfc44a9))
* **gkehub:** update the api 0fd49e0 ([33237a8](https://www.github.com/googleapis/google-api-python-client/commit/33237a8250e3becfaa1e4b5f67ef0c887cfc44a9))
* **managedidentities:** update the api 0927c19 ([c3f8675](https://www.github.com/googleapis/google-api-python-client/commit/c3f86757bccb6b42552f87d37a645651c58d6c7a))
* **managedidentities:** update the api e96adbb ([26aa9e2](https://www.github.com/googleapis/google-api-python-client/commit/26aa9e282e30ca9c8797ee5346cbe9c0b9ca65a7))
* **spanner:** update the api 87da2f3 ([26aa9e2](https://www.github.com/googleapis/google-api-python-client/commit/26aa9e282e30ca9c8797ee5346cbe9c0b9ca65a7))


### Bug Fixes

* update content-length header for next page ([#1404](https://www.github.com/googleapis/google-api-python-client/issues/1404)) ([8019f2f](https://www.github.com/googleapis/google-api-python-client/commit/8019f2f96abc6a4375873becb2f17b399f738654)), closes [#1403](https://www.github.com/googleapis/google-api-python-client/issues/1403)
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
schweikert added a commit to GoogleCloudPlatform/gcpdiag that referenced this issue Jul 19, 2021
Now that
googleapis/google-api-python-client#1403 is
fixed, remove the workaround.

Fixes: b/190349928
Change-Id: Ia278d6aefa9508be548888a1bc2d83fa59a12541
GitOrigin-RevId: ee9fee7a95a3b293e107f7814d32f8cd456b41f7
schweikert added a commit to GoogleCloudPlatform/gcpdiag that referenced this issue Jul 23, 2021
Now that
googleapis/google-api-python-client#1403 is
fixed, remove the workaround.

Fixes: b/190349928
Change-Id: Ia278d6aefa9508be548888a1bc2d83fa59a12541
GitOrigin-RevId: ee9fee7a95a3b293e107f7814d32f8cd456b41f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants