BatchRequestItem keeps the absolute URL, and set_url() only matches //v1.0/
还没有人认领这个 Issue。
评估
调研方向
从 msgraph_core/requests/batch_request_item.py 开始,重点关注 API_VERSION_REGEX、init 和 set_url()。使用链接的 1.5.1 gist 重现该行为,并验证 BatchRequestItem 在序列化的 batch body 中生成不带 /v1.0 或 /beta 前缀的相对 URL。
由索引模型根据 Issue 内容生成。
描述
BatchRequestItem built from a RequestInformation keeps the full https://graph.microsoft.com/v1.0/... URL, so the serialized batch body sends absolute URLs. set_url() is meant to strip the version prefix but its regex can't match a normal URL:
msgraph_core/requests/batch_request_item.py on main, same in 1.5.1 (and back to 1.3.8):
- line 24:
API_VERSION_REGEX = re.compile(r'/\/(v1.0|beta)/'), both/and\/are literal slashes in Python, so it only matches//v1.0/. Looks like a JavaScript regex literal ported as-is. - line 50:
__init__keepsrequest_information.urlafter the me-token replace, never callsset_url. - lines 101-127:
set_url()uses the regex above, so it never strips the version either.
Repro on 1.5.1: https://gist.github.com/HardMax71/156fbbad8a0ba78a789970a8ee550824
msgraph-core 1.5.1 kiota-abstractions 1.12.0
after __init__ url = 'https://graph.microsoft.com/v1.0/me'
after set_url() url = '/v1.0/me'
API_VERSION_REGEX = /\/(v1.0|beta)/
regex matches '/v1.0/me'? False | matches '//v1.0/me'? True
serialized batch body: {"requests": [{"id": "m1", "method": "POST", "url": "https://graph.microsoft.com/v1.0/users/u1/messages/m1/move", ...}]}
Three-line fix: API_VERSION_REGEX = re.compile(r'/(v1\.0|beta)(?=/|$)'), and in __init__ replace the manual assignment with self.set_url(request_information.url) (it already handles the me-token, query string and fragment). We currently strip the prefix by hand before building items.
- 主要语言
- Python
- 星标
- 288
- 派生
- 52
- 平均合并
- 8 小时 10 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoftgraph/msgraph-sdk-python-core 的其他 Issue
-
status:waiting-for-triage type:bug
难度 2/5 1-3 小时 新手友好度 75/100
-
status:waiting-for-triage type:bug
难度 2/5 1-3 小时 新手友好度 68/100
microsoftgraph/msgraph-sdk-python-core#1030 · 2 条评论 · 4 个 reaction ·
-
status:waiting-for-triage type:feature
难度 3/5 1-2 天 新手友好度 52/100
-
status:waiting-for-triage type:bug
难度 3/5 1-2 天 新手友好度 48/100
-
status:waiting-for-triage
难度 5/5 一周以上 新手友好度 15/100
microsoftgraph/msgraph-sdk-python-core#935 · 1 个 reaction ·
查看 microsoftgraph/msgraph-sdk-python-core 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
zostera/django-bootstrap4#894 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
use-agent-os/agent-os#3276 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#117848 ·