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
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.
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-aliasis 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
v2orv2beta1for dialogflow using librarian.Output:
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.
API client name and version
No response
Reproduction steps: code
file: main.py
Reproduction steps: supporting files
file: mydata.csv
Reproduction steps: actual results
file: output.txtmydata.csv
Reproduction steps: expected results
file: output.txtmydata.csv
OS & version + platform
No response
Python environment
No response
Python dependencies
No response
Additional context
No response