Skip to content

feat(api_core): add request-id auto-population logic to gapic_v1 public helpers#17738

Merged
hebaalazzeh merged 6 commits into
mainfrom
feat/gapic-centralization-api-core-request-id
Jul 17, 2026
Merged

feat(api_core): add request-id auto-population logic to gapic_v1 public helpers#17738
hebaalazzeh merged 6 commits into
mainfrom
feat/gapic-centralization-api-core-request-id

Conversation

@hebaalazzeh

@hebaalazzeh hebaalazzeh commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Introduces requests module containing setup_request_id helper. Exposes the module as public in gapic_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).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@hebaalazzeh
hebaalazzeh marked this pull request as ready for review July 16, 2026 15:20
@hebaalazzeh
hebaalazzeh requested a review from a team as a code owner July 16, 2026 15:20
@hebaalazzeh hebaalazzeh self-assigned this Jul 16, 2026
@hebaalazzeh
hebaalazzeh requested a review from parthea July 16, 2026 15:20
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-centralization-api-core-request-id branch from a0bff77 to 613b392 Compare July 16, 2026 16:18
@hebaalazzeh

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread packages/google-api-core/google/api_core/gapic_v1/method_helpers.py Outdated
Comment thread packages/google-api-core/tests/unit/gapic/test_method_helpers.py Outdated
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-centralization-api-core-request-id branch 3 times, most recently from e02ee4b to db040bb Compare July 16, 2026 16:28
Comment thread packages/google-api-core/google/api_core/gapic_v1/method_helpers.py Outdated
Comment thread packages/google-api-core/google/api_core/gapic_v1/requests.py
@hebaalazzeh hebaalazzeh changed the title feat: move request-id auto-population logic to gapic_v1 public helpers chore(api_core): move request-id auto-population logic to gapic_v1 public helpers Jul 16, 2026
Comment thread packages/google-api-core/tests/unit/gapic/test_request.py Outdated
Comment thread packages/google-api-core/google/api_core/gapic_v1/requests.py
…lic helpers

Introduces method_helpers module containing setup_request_id helper. Exposes the module as public in gapic_v1.
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-centralization-api-core-request-id branch 2 times, most recently from 8e31d83 to 20adea6 Compare July 16, 2026 23:42
@hebaalazzeh hebaalazzeh reopened this Jul 17, 2026
@hebaalazzeh

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread packages/google-api-core/google/api_core/gapic_v1/requests.py
Comment thread packages/google-api-core/tests/unit/gapic/test_requests.py

@daniel-sanche daniel-sanche left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@daniel-sanche daniel-sanche changed the title chore(api_core): move request-id auto-population logic to gapic_v1 public helpers feat(api_core): add request-id auto-population logic to gapic_v1 public helpers Jul 17, 2026
@hebaalazzeh
hebaalazzeh merged commit 68e1313 into main Jul 17, 2026
40 checks passed
@hebaalazzeh
hebaalazzeh deleted the feat/gapic-centralization-api-core-request-id branch July 17, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants