Batch response: Improved error handling when "UserCollectionResponse" is returned but discrimiator is set to "User"
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse y sigue cómo el body anidado de una respuesta POST $batch se pasa al nodo de parseo. Revisa BatchResponseContentCollection#getResponseById y la reproducción JSON anidada proporcionada. Se considera completado cuando los objetos UserCollectionResponse anidados se analizan correctamente, con un error adecuado para las respuestas que no se puedan analizar.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Graph Core Version: 3.1.9
Kiota Version: 1.1.7
Affected Method: com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse
Edit: Added a comment explaining the reason of this behavior and changed the issue title.
Microsoft Graph core returns an object with all properties set to null, if the response body contains a nested structure.
Expected behavior
com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse should parse nested response objects. And maybe throw an error if a response can not be parsed.
Actual behavior
com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse returns a object with all properties set to null.
Steps to reproduce the behavior
Execute the following request using the Graph API: POST https://graph.microsoft.com/v1.0/$batch
Body is GET users?$filter=identities/any(c:c/issuerAssignedId eq '<the issuer Assigned id>' and c/issuer eq 'contoso.com')&$select=id,displayName,email,UserPrincipalName,identities,accountEnabled
{
"requests": [
{
"id": "d26195f1-aa54-461f-9119-aa98687ea27e",
"url": "/users?%24filter=identities%2Fany% ... ",
"method": "GET",
"headers": {
"accept": "application/json"
}
}
]
}
Response: shortended just to show the structure. Note the nested structure in the body which causes the erroneous behavior.
{
"responses": [
{
"id": "766378b9-df71-473d-909a-da07fa9f10c5",
"status": 200,
"headers": {...},
"body": {
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,email,userPrincipalName,identities,accountEnabled)",
"value": [
{
"id": "<some Id>",
"displayName": "John Doe",
"userPrincipalName": "cpim_something",
"accountEnabled": false,
"identities": [...]
}
]
}
}
]
}
The image shows the structure of parseNode in com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse for a Request that CAN NOT be parsed:
The image shows the structure of parseNode in com.microsoft.graph.core.requests.ResponseBodyHandler#handleResponse for a request that CAN be parsed:
Remarks
I verified this by unnesting the structure and re-parsing the response:
ByteArrayInputStream unnestedResponse = new ByteArrayInputStream(((java.util.ArrayList)((JsonArray)((com.google.gson.internal.LinkedTreeMap.Node)((com.google.gson.internal.LinkedTreeMap)((JsonObject)((JsonParseNode)parseNode).currentNode).members).entrySet().toArray()[1]).getValue()).elements).get(0).toString().getBytes());
String contentType = body.contentType().type() + "/" + body.contentType().subtype();
this.parseNodeFactory
.getParseNode(contentType, unnestedResponse)
.getObjectValue(this.factory);
An intermediate fix (not yet tested) could be to provide your own implementation of ResponseBodyHandler when invoking com.microsoft.graph.core.content.BatchResponseContentCollection#getResponseById(java.lang.String, com.microsoft.kiota.ResponseHandler)
- Lenguaje dominante
- Java
- Estrellas
- 67
- Forks
- 34
- Métricas de merge de PR
- Sin PR fusionados en 30 d
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.
Más de microsoftgraph/msgraph-sdk-java-core
-
upgrade to okhttp 5 Abiertoenhancement help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
microsoftgraph/msgraph-sdk-java-core#684 · 12 comentarios · 1 reacción ·
-
Add support for OSGI bundles Abiertoenhancement kiota
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
microsoftgraph/msgraph-sdk-java-core#414 · 12 comentarios ·
Todos los issues de microsoftgraph/msgraph-sdk-java-core
Issues similares
-
Bug Java Platform: Java
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
getsentry/sentry-java#6138 · 1 comentario ·
-
bug needs triage p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 comentario ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/rocketmq-dashboard#4654 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100