BatchRequestItem loses query parameters from RequestInformation
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Inizia da src/msgraph_core/requests/batch_request_item.py, alle righe del costruttore collegate nell’issue, quindi confronta il comportamento di RequestInformation.url e query_parameters nel file kiota-python indicato. Esegui la riproduzione fornita per confermare che il body del batch omette i parametri; il lavoro è completato quando i parametri di query compaiono nel body della richiesta batch.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 288
- Fork
- 53
- Merge medio
- 40m
- PR unite (30g)
- 1
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoftgraph/msgraph-sdk-python-core
-
Logging to root loggerApertastatus:waiting-for-triage type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoftgraph/msgraph-sdk-python-core#1078 ·
I maintainer di solito rispondono entro 1 giorno
-
Missing 'deprecated' dependencyForse già presa @Daiyuanranfeng l’ha presa 3 giorni fa. Apertastatus:waiting-for-triage type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoftgraph/msgraph-sdk-python-core#1030 · 4 commenti · 4 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Replace httpx with httpx2Apertastatus:waiting-for-triage type:feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
microsoftgraph/msgraph-sdk-python-core#1115 ·
I maintainer di solito rispondono entro 1 giorno
-
status:waiting-for-triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
microsoftgraph/msgraph-sdk-python-core#935 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
type:bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
microsoftgraph/msgraph-sdk-python-core#917 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoftgraph/msgraph-sdk-python-core
Issue simili
-
tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Plugin] 群聊记忆 · 人格养成Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 74/100
-
bug maintainer-managed
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
awslabs/visual-asset-management-system#1759 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100