OpenAPI parser doesn't let an operation parameter override the path-level one: the model is asked for the same path value twice, and the wrong one is sent
维护者通常 5 天内回复
@llalitkumarrr 已经在做这个了。
开始于 2026年9月21日。
评估
调研方向
从 OpenApiSpecParser._collect_operations() 开始,运行提供的 httpx.MockTransport 复现代码,以观察重复的参数和请求 URL。检查 OperationParser 的参数处理以及报告中的 PR 测试,然后确认操作级参数只使用一次,同时其他位置的同名参数仍然有效。
由索引模型根据 Issue 内容生成。
描述
🔴 Required Information
Describe the Bug:
OpenApiSpecParser._collect_operations() appends path-level parameters to every operation's own parameters without checking for overrides:
operation_dict["parameters"] = operation_dict.get("parameters", []) + path_item.get("parameters", [])
The OpenAPI 3 Path Item Object says an operation-level parameter with the same name and in overrides the path-level one. Declaring the shared path parameter once at the path level and refining it on an operation (a more specific description, pattern or enum) is common. ADK keeps both, OperationParser de-duplicates the names, and the tool then asks the model for the same URL segment twice as two required arguments: account_id and account_id_0. When the model fills both, both map to the same {accountId} placeholder and the path-level value wins, so the operation's own, more specific parameter is silently dropped from the request.
Steps to Reproduce:
pip install google-adk(reproduced onmain@ 3f4bb8fa).- Run the script below: an
OpenAPIToolsetwhose/accounts/{accountId}path declaresaccountIdand whoseGEToverrides it. HTTP goes to anhttpx.MockTransport.
Expected Behavior:
One required argument, account_id, described by the operation-level parameter; {"account_id": "ACC-123"} requests /accounts/ACC-123.
Observed Behavior:
model is asked for: ['account_id', 'account_id_0']
args: {'account_id': 'ACC-123', 'account_id_0': 'ACC-999'} -> request: https://crm.example.com/accounts/ACC-999
Environment Details:
- ADK Library Version (pip show google-adk):
main@ 3f4bb8fa - Desktop OS: Windows 11
- Python Version (python -V): 3.12.10
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A (tool declaration and request building)
🟡 Optional Information
Minimal Reproduction Code:
import asyncio
import httpx
from google.adk.tools.openapi_tool.openapi_spec_parser.openapi_toolset import OpenAPIToolset
spec = {
"openapi": "3.0.0",
"info": {"title": "CRM", "version": "1"},
"servers": [{"url": "https://crm.example.com"}],
"paths": {"/accounts/{accountId}": {
"parameters": [{"name": "accountId", "in": "path", "required": True,
"schema": {"type": "string"}, "description": "Shared account id"}],
"get": {
"operationId": "getAccount",
"parameters": [{"name": "accountId", "in": "path", "required": True,
"schema": {"type": "string", "pattern": "^ACC-[0-9]+$"},
"description": "Account id, e.g. ACC-123"}],
"responses": {"200": {"description": "ok"}},
},
}},
}
sent = []
toolset = OpenAPIToolset(
spec_dict=spec,
httpx_client_factory=lambda: httpx.AsyncClient(transport=httpx.MockTransport(
lambda r: sent.append(str(r.url)) or httpx.Response(200, json={}))),
)
async def main():
tool = (await toolset.get_tools())[0]
schema = tool._get_declaration().parameters_json_schema
print("model is asked for:", schema["required"])
args = {"account_id": "ACC-123"}
if "account_id_0" in schema["properties"]:
args["account_id_0"] = "ACC-999" # a model filling both required fields
await tool.run_async(args=args, tool_context=None)
print("args:", args, "-> request:", sent[0])
asyncio.run(main())
Suggested fix: when merging, skip path-level parameters whose (name, in) the operation already declares. Parameters with the same name but a different location are still merged. I have a PR ready with a test.
How often has this issue occurred?:
- Always (100%): any spec that overrides a path-level parameter on an operation.
- 主要语言
- Python
- 星标
- 21.6k
- 派生
- 4k
- 平均合并
- 9 小时 59 分钟
- 30 天内合并 PR
- 5
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/adk-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
google/adk-python#7385 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
google/adk-python#7381 ·
维护者通常 5 天内回复
-
[A2A] RemoteA2aAgent(use_legacy=False): extension header written to state['http_kwargs'], ignored by a2a-sdk 1.x transports可能已有人在做 @surajksharma07 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
google/adk-python#7334 · 2 条评论 · 已指派 1 人 ·
维护者通常 5 天内回复
-
GoogleOidcVerifier treats string "false" as a verified email claim可能已有人在做 @surajksharma07 于 5 天前认领。 未关闭core
难度 2/5 1-3 小时 新手友好度 82/100
google/adk-python#7289 · 5 条评论 · 已指派 1 人 ·
维护者通常 5 天内回复
-
RestApiTool raises uncaught KeyError when a required path param is omitted可能已有人在做 @llalitkumarrr 于 5 天前认领。 未关闭request clarification tools
难度 2/5 1-3 小时 新手友好度 78/100
google/adk-python#7282 · 5 条评论 · 已指派 1 人 ·
维护者通常 5 天内回复
查看 google/adk-python 的全部 Issue
相似的 Issue
-
good first issue hacktoberfest
难度 1/5 1 小时以内 新手友好度 92/100
维护者通常 1 天内回复
-
tool-calling
难度 2/5 1-3 小时 新手友好度 88/100
vllm-project/vllm#59838 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
raullenchai/Rapid-MLX#4042 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 92/100
transitmatters/mbta-slow-zone-bot#70 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
open-webui/open-webui#31871 · 1 条评论 ·
维护者通常 1 天内回复