feat(api_core): add request-id auto-population logic to gapic_v1 public helpers#17738
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new helper module method_helpers containing a setup_request_id function to populate a UUID4 field in requests if not already set, supporting dicts, protobuf, and proto-plus messages. It also adds a session-scoped pytest fixture to isolate unit tests from workstation mTLS environments, updates a nox session configuration, and relaxes a timing assertion in test_bidi.py. As there are no review comments, no additional feedback is provided.
a0bff77 to
613b392
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new helper module method_helpers containing the setup_request_id function, which populates a UUID4 field in request objects or dictionaries if not already set, along with corresponding unit tests. The review feedback suggests adding a None check at the beginning of setup_request_id and using a default value in getattr to prevent potential AttributeErrors, as well as adding a test case to verify graceful handling of None requests.
e02ee4b to
db040bb
Compare
…lic helpers Introduces method_helpers module containing setup_request_id helper. Exposes the module as public in gapic_v1.
…t and improve docstring
8e31d83 to
20adea6
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new helper module request.py in gapic_v1 to automatically populate a UUID4 request ID field for API requests (supporting both protobuf messages and dictionaries) to ensure idempotency. It also includes comprehensive unit tests for this new functionality. The review feedback suggests improving the robustness of the dictionary handling in setup_request_id by ensuring that fields explicitly set to None are also populated with a UUID, and recommends adding corresponding test cases to verify this behavior.
Introduces
requestsmodule containingsetup_request_idhelper. Exposes the module as public ingapic_v1.The unit tests in test_method_helpers.py are now identical to the generator's original test template test_service.py.j2 (with the exception of our added None request test case).