Adding request info does not use specified request_id for BatchRequestContent
還沒有人認領這個 Issue。
評估
研究方向
從 msgraph_core/requests/batch_request_content.py 中的 add_request_information 開始,追蹤 BatchRequestItem 在 msgraph_core/requests/batch_request_item.py 中的建立方式。確認提供的 request_id 仍然是該項目的 ID,並確認未提供自訂 ID 時產生的 ID 仍然有效。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
Trying to add batch request steps with custom request IDs so that I can track the responses, however the custom request ID is always overridden to a random uuid
Expected behavior
Should be able to specify a custom request ID as specified in the function doc strings and in samples.
How to reproduce
You can track this through:
msgraph_core/requests/batch_request_content.py
def add_request_information(
self, request_information: RequestInformation, request_id: Optional[str] = None
) -> None:
"""
Adds a request to the batch request content.
Args:
request_information (RequestInformation): The request information to add.
request_id: Optional[str]: The request id to add.
"""
request_id = request_id if request_id else str(uuid.uuid4())
self.add_request(request_id, BatchRequestItem(request_information))
When creating the BatchRequestItem (msgraph_core/requests/batch_request_item.py), we've not passed the request ID into the init, so a random one is assigned to the Item:
def __init__(
self,
request_information: Optional[RequestInformation] = None,
id: str = "",
depends_on: Optional[list[Union[str, 'BatchRequestItem']]] = []
):
"""
Initializes a new instance of the BatchRequestItem class.
Args:
request_information (RequestInformation): The request information.
id (str, optional): The ID of the request item. Defaults to "".
depends_on (Optional[list[Union[str, BatchRequestItem]], optional):
The IDs of the requests that this request depends on. Defaults to None.
"""
if request_information is None or not request_information.http_method:
raise ValueError("HTTP method cannot be Null/Empty")
self._id = id or str(uuid4())
The custom one is then only used if there isn't one already on the request, which is impossible here because of the initialisation of the item object:
def add_request(self, request_id: Optional[str], request: BatchRequestItem) -> None:
"""
Adds a request to the batch request content.
Args:
request_id (Optional[str]): The request id to add.
request (BatchRequestItem): The request to add.
"""
if len(self.requests) >= BatchRequestContent.MAX_REQUESTS:
raise RuntimeError(f"Maximum number of requests is {BatchRequestContent.MAX_REQUESTS}")
if not request.id:
request.id = request_id if request_id else str(uuid.uuid4())
So it's impossible for you to set a custom request ID through the add_request_information function. Either we should pass the custom one into the initialisation of the Item, or the "add_request" function should be checking for whether we have a request_id not a request.id. Suspect it should be the latter otherwise the function signature makes no sense.
SDK Version
1.17.0 of the SDK, 1.20.0 of msgraph-core
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
- 主要語言
- Python
- 星號
- 288
- 分支
- 52
- 平均合併
- 8 小時 10 分鐘
- 30 天內合併 PR
- 1
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoftgraph/msgraph-sdk-python-core 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
-
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
查看 microsoftgraph/msgraph-sdk-python-core 的全部 Issue
相似的 Issue
-
link-check link-check:sphinx-theme
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難度 2/5 1-3 小時 新手友好度 88/100
OpenHands/extensions#626 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
CSCfi/sd-search-api#39 ·
-
難度 1/5 1 小時以內 新手友好度 90/100