feat: request compact JSON responses by default - #2789
Conversation
Google APIs default prettyPrint to true, so every JSON response carries indentation and line breaks that the client throws away while parsing. JsonModel now sends prettyPrint=false, mirroring the existing alt_param mechanism. Fixes googleapis#2788
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request configures the client library to request compact JSON responses by default by appending prettyPrint=false to API requests, which reduces network transfer and parsing overhead. It also updates the documentation and tests to reflect this change. The feedback highlights a potential issue where mutating the params dictionary in _build_query can cause side effects for callers, suggesting that a local copy of the dictionary should be created instead.
| if self.alt_param is not None: | ||
| params.update({"alt": self.alt_param}) |
There was a problem hiding this comment.
Mutating the params dictionary passed as an argument to _build_query can lead to unexpected side effects for the caller, especially if the dictionary is reused (e.g., in retries, batching, or by the client application). It is safer to create a local copy of the dictionary using dict(params) before modifying it.
| if self.alt_param is not None: | |
| params.update({"alt": self.alt_param}) | |
| params = dict(params) | |
| if self.alt_param is not None: | |
| params.update({"alt": self.alt_param}) |
Google APIs default prettyPrint to true, so every JSON response carries indentation and line breaks that the client throws away while parsing. JsonModel now sends prettyPrint=false, mirroring the existing alt_param mechanism.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #2788 馃