[WIP] Update gapic v1.38 - #18082
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the REST transport layer across the google-cloud-build and google-cloud-iam packages by centralizing request transcoding logic into new _compat.py modules. It removes legacy version check logic and redundant _get_unset_required_fields methods, replacing them with a centralized transcode_request function. Additionally, it updates dependency constraints and adds a disable_mtls_env fixture to unit tests. The reviewer identified two issues in the new _compat.py files where dictionary-like access was incorrectly used on a NamedTuple returned by path_template.transcode, and provided code suggestions to use attribute access instead.
| if transcoded_request.get("body") is not None: | ||
| body_json = json_format.MessageToJson( | ||
| transcoded_request["body"], |
There was a problem hiding this comment.
The transcoded_request object returned by path_template.transcode is a NamedTuple (TranscodedRequest), which does not support dictionary-like .get() access or string-based indexing (e.g., transcoded_request["body"]). Attempting to use .get() will raise an AttributeError, and string indexing will raise a TypeError. Please use attribute access instead (e.g., transcoded_request.body and transcoded_request.query_params).
| if transcoded_request.get("body") is not None: | |
| body_json = json_format.MessageToJson( | |
| transcoded_request["body"], | |
| if transcoded_request.body is not None: | |
| body_json = json_format.MessageToJson( | |
| transcoded_request.body, |
| query_params_json = {} | ||
| if transcoded_request.get("query_params") is not None: | ||
| query_params_json = json.loads( | ||
| json_format.MessageToJson( | ||
| transcoded_request["query_params"], |
There was a problem hiding this comment.
The transcoded_request object returned by path_template.transcode is a NamedTuple (TranscodedRequest), which does not support dictionary-like .get() access or string-based indexing (e.g., transcoded_request["query_params"]). Attempting to use .get() will raise an AttributeError, and string indexing will raise a TypeError. Please use attribute access instead (e.g., transcoded_request.query_params).
| query_params_json = {} | |
| if transcoded_request.get("query_params") is not None: | |
| query_params_json = json.loads( | |
| json_format.MessageToJson( | |
| transcoded_request["query_params"], | |
| query_params_json = {} | |
| if transcoded_request.query_params is not None: | |
| query_params_json = json.loads( | |
| json_format.MessageToJson( | |
| transcoded_request.query_params, |
ffa5197 to
88026bb
Compare
88026bb to
4ede4ac
Compare
WIP