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

Offen Anfängerfreundlich
#1,116 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
api

Rechercherichtung

Beginne in msgraph_core/requests/batch_request_item.py und konzentriere dich auf API_VERSION_REGEX, init und set_url(). Reproduziere das Verhalten mit dem verlinkten 1.5.1 gist und überprüfe, dass ein BatchRequestItem im serialisierten Batch-Body eine relative URL ohne das Präfix /v1.0 oder /beta erzeugt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
288
Forks
52
Ø Merge
8 Std. 10 Min.
Gemergte PRs (30 T.)
1

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoftgraph/msgraph-sdk-python-core

Alle Issues in microsoftgraph/msgraph-sdk-python-core

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.