Skip to content

fix: restore messages not attached to rpc in selective_gapic_generation#16951

Draft
parthea wants to merge 2 commits into
mainfrom
selective-gapic-restore-messages-not-attached-to-any-rpc
Draft

fix: restore messages not attached to rpc in selective_gapic_generation#16951
parthea wants to merge 2 commits into
mainfrom
selective-gapic-restore-messages-not-attached-to-any-rpc

Conversation

@parthea
Copy link
Copy Markdown
Contributor

@parthea parthea commented May 5, 2026

Towards b/507893758, b/507889482, b/501132869, b/503326310

Copy link
Copy Markdown
Contributor

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

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 refactors the selective GAPIC generation logic by replacing the multi-step allowlist and pruning process with a unified with_selective_generation method across the Proto, Service, and Method classes. This consolidation simplifies the code by handling both internal method marking and service/method omission in a single pass. The review feedback highlights the need for docstrings on the new methods and recommends updating return type hints to Optional to correctly handle cases where objects are filtered out (returning None). Specifically, the Proto implementation should be updated to return None if it becomes empty after filtering.

Comment thread packages/gapic-generator/gapic/schema/api.py Outdated
Comment thread packages/gapic-generator/gapic/schema/wrappers.py
Comment thread packages/gapic-generator/gapic/schema/wrappers.py
@parthea parthea self-assigned this May 11, 2026
@parthea parthea force-pushed the selective-gapic-restore-messages-not-attached-to-any-rpc branch from 5d8ec63 to 22ddb97 Compare May 12, 2026 16:38
@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented May 12, 2026

/gemini review

Copy link
Copy Markdown
Contributor

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

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 refactors the selective GAPIC generation logic by consolidating several methods into a unified with_selective_generation implementation across the Proto, Service, and Method classes. The updated logic refines how messages are pruned, ensuring that only top-level request/response messages of omitted RPCs are excluded while keeping other reachable types. Review feedback highlights missing docstrings and incorrect return type hints for the new methods, which should be updated to Optional where None can be returned. Additionally, there is a concern regarding potential non-determinism in the global service mapping used for cross-proto lookups.

Comment thread packages/gapic-generator/gapic/schema/api.py
Comment thread packages/gapic-generator/gapic/schema/api.py
Comment thread packages/gapic-generator/gapic/schema/wrappers.py
Comment thread packages/gapic-generator/gapic/schema/wrappers.py
@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented May 12, 2026

/gemini review

Copy link
Copy Markdown
Contributor

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

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 refactors the selective GAPIC generation logic to more precisely control which components are excluded. It replaces several pruning methods with a unified with_selective_generation approach that targets only the top-level request and response messages of omitted RPCs for exclusion, while preserving other reachable messages. Additionally, the Address class hash function was updated to exclude api_naming to maintain the hash contract. Review feedback highlighted a potential collision risk in the global service map used for extended LROs, suggesting the use of fully qualified names instead of short names to ensure correct resolution.

Comment thread packages/gapic-generator/gapic/schema/api.py Outdated
@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented May 12, 2026

/gemini review

Copy link
Copy Markdown
Contributor

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

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 refactors the selective GAPIC generation logic by consolidating pruning and internal-marking functionality into a unified with_selective_generation method across the schema classes. The changes improve the precision of message exclusion, ensuring that only top-level request/response messages of omitted RPCs are removed while keeping reachable dependencies. Additionally, the Address class's hash function was updated to support its use as a dictionary key. A critical bug was identified in the global service lookup map where a type mismatch between string keys and Address object lookups would result in a KeyError during extended LRO processing.

Comment thread packages/gapic-generator/gapic/schema/api.py Outdated
@parthea parthea force-pushed the selective-gapic-restore-messages-not-attached-to-any-rpc branch 3 times, most recently from 552034c to 5dbd520 Compare May 12, 2026 19:14
@parthea parthea force-pushed the selective-gapic-restore-messages-not-attached-to-any-rpc branch from 5dbd520 to a532424 Compare May 12, 2026 19:20
@parthea parthea force-pushed the selective-gapic-restore-messages-not-attached-to-any-rpc branch from ba521c2 to 7915ee3 Compare May 12, 2026 20:01
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.

1 participant