microsoftgraph / microsoftgraph/msgraph-sdk-python-core

BatchRequestItem keeps the absolute URL, and set_url() only matches //v1.0/

未關閉 適合新手
#1,116 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
288
分支
52
平均合併
8 小時 10 分鐘
30 天內合併 PR
1

描述

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__ keeps request_information.url after the me-token replace, never calls set_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.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 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 內容生成。

評估

技術堆疊
python
領域
api
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
描述清楚
新手友好度
88/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。