OpenAPI duplicate parameter suffixes collide with existing parameter names
Describe the bug
OpenAPI parameters at different locations may share a name. If one of the other parameters already has a numeric suffix, OperationParser._dedupe_param_names can generate that same name for a duplicate. The declaration silently loses a parameter, and RestApiTool cannot route all values to their original HTTP locations.
For example, an operation with query id, header id, and query id_0 produces Python names id, id_0, id_0. The schema has only two properties. RestApiTool._prepare_request_params builds a dictionary by those names, so the query parameter replaces the header parameter and the id header is never sent.
This also affects object-body properties and preserve_property_names=True.
Minimal reproduction
from google.adk.tools.openapi_tool.openapi_spec_parser.operation_parser import OperationParser
parser = OperationParser({
"operationId": "lookup",
"parameters": [
{"name": name, "in": location, "schema": {"type": "string"}}
for name, location in [("id", "query"), ("id", "header"), ("id_0", "query")]
],
})
print([(p.original_name, p.param_location, p.py_name) for p in parser.get_parameters()])
print(list(parser.get_json_schema()["properties"]))
Actual:
[('id', 'query', 'id'), ('id', 'header', 'id_0'), ('id_0', 'query', 'id_0')]
['id', 'id_0']
Expected: three distinct declaration names; retain the original id_0 and assign another free suffix to the header parameter.
Environment and validation
- ADK
mainat12aab4aaa, Python 3.12.10, Windows. - No model or external credentials are involved.
- Also reproduced through
OpenAPIToolset.get_tools()andRestApiTool.run_async()against a real local HTTP echo server. The server receives noidheader before the fix; after reserving original parameter names during suffix allocation it receives the header, both query parameters, and the body independently.
The proposed fix reserves all existing Python parameter names before generating suffixes, preserving ordinary name, name_0, name_1 behavior when no original parameter occupies those names.
Thanks for the report and repro, @1aifanatic.
I confirmed the bug on main and verified that #8136 addresses it. Issue repro and edge cases (body properties, preserve_property_names=True, nested suffixes) now produce unique names.
The PR is currently under review and will be merged once approved.