microsoftgraph / microsoftgraph/msgraph-sdk-python-core

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

Ouverte Adaptée aux débutants
#1,116 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Python
Étoiles
288
Forks
52
Merge moyen
8 h 10 min
PR mergées (30 j)
1

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__ 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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez dans msgraph_core/requests/batch_request_item.py, en vous concentrant sur API_VERSION_REGEX, init et set_url(). Reproduisez le comportement avec le gist 1.5.1 lié et vérifiez qu’un BatchRequestItem produit une URL relative sans le préfixe /v1.0 ou /beta dans le corps de batch sérialisé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
api
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
Active
Clarté
Clairement spécifiée
Accessibilité débutants
88/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.