microsoftgraph / microsoftgraph/msgraph-sdk-python-core

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

Aperta Adatta ai principianti
#1,116 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
288
Fork
52
Merge medio
8h 10m
PR unite (30g)
1

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in msgraph_core/requests/batch_request_item.py, concentrandoti su API_VERSION_REGEX, init e set_url(). Riproduci il comportamento con il gist collegato della versione 1.5.1 e verifica che un BatchRequestItem produca un URL relativo senza il prefisso /v1.0 o /beta nel corpo batch serializzato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
88/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.