You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gapic-generator: --resource-name-alias is ignored for file-level resource definitions, causing false-positive namespace collisions #16952
When generating a client library that imports an external dependency with a file-level resource definition (e.g., google.api.resource_definition), the generator falsely throws a namespace collision error even if an explicit --resource-name-alias is provided via the CLI/Bazel arguments. The generator's AST builder fails to pass the alias dictionary to the dummy MessageType constructed for file-level resources.
Steps to Reproduce
Set the following option in BUILD.bazel file for dialogflow:
Regenerate v2 or v2beta1 for dialogflow using librarian.
Output:
ValueError:
Fatal: Namespace collision detected for resource type 'Tool'.
Resources 'ces.googleapis.com/Tool' and 'dialogflow.googleapis.com/Tool' both flatten to the exact same method name.
To protect backward compatibility, explicitly alias one of these using the `--resource-name-alias` CLI parameter.
Root Cause Analysis
The bug exists in the hand-off between api.py and wrappers.py.
File-level resources bypass the standard _load_message pipeline where CLI aliases are normally injected. Instead, they are parsed in api.py inside the Proto.resource_messages property, which relies on wrappers.CommonResource.build(res) to spin up a dummy MessageType.
Activity
fix: pass resource aliases to file-level CommonResources (#16945)