BatchRequestItem keeps the absolute URL, and set_url() only matches //v1.0/
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in msgraph_core/requests/batch_request_item.py, focusing on API_VERSION_REGEX, init, and set_url(). Reproduce the behavior with the linked 1.5.1 gist and verify that a BatchRequestItem produces a relative URL without the /v1.0 or /beta prefix in the serialized batch body.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 288
- Forks
- 52
- Avg merge
- 8h 10m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoftgraph/msgraph-sdk-python-core
-
status:waiting-for-triage type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
status:waiting-for-triage type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoftgraph/msgraph-sdk-python-core#1030 · 2 comments · 4 reactions ·
-
status:waiting-for-triage type:feature
Difficulty 3/5 1-2 days Newbie friendliness 52/100
-
status:waiting-for-triage type:bug
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
status:waiting-for-triage
Difficulty 5/5 Over a week Newbie friendliness 15/100
microsoftgraph/msgraph-sdk-python-core#935 · 1 reaction ·
All issues in microsoftgraph/msgraph-sdk-python-core
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100