OpenAPI tools ignore operation- and path-level server overrides
维护者通常 3 天内回复
评估
调研方向
基础 URL 会从 openapi_spec_parser.py 中根级的 servers 列表一次性选出,位于 OpenApiSpecParser.parse 中逐个操作的循环之外,并被每个 OperationEndpoint 复用。请先阅读该循环,然后阅读 rest_api_tool.py 中 RestApiTool.from_parsed_operation 和 _prepare_request_params 的请求构建逻辑,并运行 issue 中的复现脚本。完成的标准是:带有操作级服务器的 GET 使用该服务器;只带路径级服务器的 POST 使用该服务器;未声明的情况仍回退到根服务器;解析器测试覆盖每一层级。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
OpenApiSpecParser always uses the root servers[0].url, even when a path item or an operation declares its own servers. Per the OpenAPI spec (Operation Object / Path Item Object), operation servers override path servers, and path servers override root servers. So every generated RestApiTool sends requests to the root server.
Root cause: openapi_spec_parser.py picks the root server once, outside the operation loop, and reuses it as base_url for every OperationEndpoint.
To reproduce (offline, on main)
from google.adk.tools.openapi_tool.openapi_spec_parser.openapi_spec_parser import OpenApiSpecParser
from google.adk.tools.openapi_tool.openapi_spec_parser.rest_api_tool import RestApiTool
spec = {'openapi': '3.0.0', 'info': {'title': 'demo', 'version': '1'},
'servers': [{'url': 'https://root.example.test/v1'}],
'paths': {'/items': {
'servers': [{'url': 'https://path.example.test/v2'}],
'get': {'operationId': 'listItems',
'servers': [{'url': 'https://operation.example.test/v3'}],
'responses': {'200': {'description': 'OK'}}},
'post': {'operationId': 'addItem',
'responses': {'200': {'description': 'OK'}}}}}}
for parsed in OpenApiSpecParser().parse(spec):
tool = RestApiTool.from_parsed_operation(parsed)
request = tool._prepare_request_params(tool._operation_parser.get_parameters(), {})
print(parsed.endpoint.method.upper(), request['url'])
Expected: GET https://operation.example.test/v3/items and POST https://path.example.test/v2/items.
Actual: both go to https://root.example.test/v1/items.
Environment: ADK main (2.14.0), Python 3.11, macOS. No model involved.
I'd like to send a fix: choose the server per operation (operation, then path, then root, keeping the current fallback when none is declared), with parser tests for each level.
- 主要语言
- Python
- 星标
- 22.3k
- 派生
- 4.4k
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/adk-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
google/adk-python#8360 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
google/adk-python#8359 ·
维护者通常 3 天内回复
-
Can pin to litellm version be changed?可能已有人在做 @llalitkumarrr 于 10 天前认领。 未关闭models
难度 1/5 1 小时以内 新手友好度 65/100
google/adk-python#8129 · 2 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
-
Two docstrings in openapi_tool document parameters the signatures do not accept可能已有人在做 @surajksharma07 于 17 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
google/adk-python#8024 · 1 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
-
`adk run` does not support arrow keys or input history可能已有人在做 @llalitkumarrr 于 17 天前认领。 未关闭cli
难度 1/5 1-3 小时 新手友好度 84/100
google/adk-python#8022 · 2 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
查看 google/adk-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
vllm-project/vllm#70030 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
TigreGotico/tugaphone#408 ·
维护者通常 1 天内回复
-
t: bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
needs-triage
难度 1/5 1 小时以内 新手友好度 85/100
Azure/azure-sdk-for-python#50155 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复