microsoftgraph / microsoftgraph/msgraph-sdk-python-core
BatchRequestItem keeps the absolute URL, and set_url() only matches //v1.0/
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 288
- Forks
- 52
- Merge medio
- 8 h 10 min
- PR fusionados (30 d)
- 1
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en msgraph_core/requests/batch_request_item.py, centrándote en API_VERSION_REGEX, init y set_url(). Reproduce el comportamiento con el gist enlazado de la versión 1.5.1 y verifica que un BatchRequestItem produzca una URL relativa sin el prefijo /v1.0 o /beta en el cuerpo serializado del batch.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 88/100