BatchRequestItem loses query parameters from RequestInformation
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 48/100
Piste de recherche
Commencez par src/msgraph_core/requests/batch_request_item.py, aux lignes du constructeur référencées dans l’issue, puis comparez le comportement de RequestInformation.url et query_parameters dans le fichier kiota-python indiqué. Exécutez la reproduction fournie pour confirmer que le corps du batch omet les paramètres ; le travail est terminé lorsque les paramètres de requête apparaissent dans le corps de la requête batch.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
I'm trying to peform a batched GET request with additional query parameters to select specific fields on a response.
The resulting BatchRequestItem is not aware of query parameters and will result in the request being sent without them.
After some debugging I figured out that the underlying problem is the way RequestInformation works.
It's unclear whether this is by design, at least it's very easy to use it incorrectly.
RequestInformation has a public property query_parameters. It also has a url property with getter and setter methods, which deal with __uri internally.
After setting the url property, which results in __uri being truthy, query_parameters will not be evaluated anymore in the url getter, which is used e.g. by BatchRequestItem.
It's unclear whether this is an issue with BatchRequestItem copying the parameters from RequestInformation or whether RequestInformation should include them in the url getter, in which case this issue should be moved to the repo for the microsoft-kiota-abstractions package.
Expected behavior
Query parameters included in the batch body.
How to reproduce
import asyncio
from azure.identity import AzureCliCredential
from msgraph import GraphServiceClient
from kiota_abstractions.request_information import RequestInformation
from kiota_abstractions.method import Method
from msgraph_core.requests.batch_request_item import BatchRequestItem
from msgraph_core.requests.batch_request_content import BatchRequestContent
async def main():
credential = AzureCliCredential()
client = GraphServiceClient(credentials=credential, scopes=["https://graph.microsoft.com/.default"])
request_info = RequestInformation()
request_info.http_method = Method.GET
request_info.url = "/me"
request_info.query_parameters = {
"$select": ",".join([
"id",
"userPrincipalName",
"displayName",
"accountEnabled",
])
}
batch_item = BatchRequestItem(request_information=request_info)
batch_content = BatchRequestContent({batch_item.id: batch_item})
batch_response = await client.batch.post(
batch_request_content=batch_content,
)
print(repr(batch_response.responses.get(batch_item.id).body))
asyncio.run(main())
SDK Version
1.3.8
Latest version known to work for scenario above?
No response
Known Workarounds
Append query parameters to the URL directly, e.g.
query_parameters = {
"$select": ",".join([
"id",
"userPrincipalName",
"displayName",
"accountEnabled",
])
}
request_info.url = "/me?" + urllib.parse.urlencode(query_parameters)
Debug output
N/A
Configuration
No response
Other information
The constructor for BatchRequestItem only takes the URL from the provided RequestInformation, but it doesn't take into account that there may be query parameters, so they're just ignored.
The getter for url on RequestInformation skips any further processing if __url is already truthy: https://github.com/microsoft/kiota-python/blob/microsoft-kiota-abstractions-v1.9.7/packages/abstractions/kiota_abstractions/request_information.py#L97-L102
The setter for url copies the provided URL to __url: https://github.com/microsoft/kiota-python/blob/microsoft-kiota-abstractions-v1.9.7/packages/abstractions/kiota_abstractions/request_information.py#L123-L130
- Langage dominant
- Python
- Étoiles
- 288
- Forks
- 52
- Merge moyen
- 8 h 10 min
- PR mergées (30 j)
- 1
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoftgraph/msgraph-sdk-python-core
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
Logging to root logger Ouvertestatus:waiting-for-triage type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Missing 'deprecated' dependency Ouvertestatus:waiting-for-triage type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
microsoftgraph/msgraph-sdk-python-core#1030 · 2 commentaires · 4 réactions ·
-
Replace httpx with httpx2 Ouvertestatus:waiting-for-triage type:feature
Difficulté 3/5 1-2 jours Accessibilité débutants 52/100
-
status:waiting-for-triage
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
microsoftgraph/msgraph-sdk-python-core#935 · 1 réaction ·
Toutes les issues de microsoftgraph/msgraph-sdk-python-core
Issues similaires
-
link-check link-check:sphinx-theme
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
OpenHands/extensions#626 · 1 commentaire ·
-
Change observation tooltip text Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
CSCfi/sd-search-api#39 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100