microsoftgraph / microsoftgraph/msgraph-sdk-java
BatchResponseContent fails when processing "error": null in batch responses
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 444
- Forks
- 154
- Ø Merge
- 18 Std. 28 Min.
- Gemergte PRs (30 T.)
- 4
Beschreibung
Description
The SDK throws IllegalStateException while processing batch responses when the body.error field is explicitly present but set to null.
The following exception is thrown:
java.lang.IllegalStateException: Not a JSON Object: null
at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:91)
at com.microsoft.graph.core.content.BatchResponseContent.getResponseFromJsonObject(BatchResponseContent.java:199)
Expected behavior
The SDK should ignore error: null and correctly process value.
How to reproduce
Create a batch request with a countIf operation in Microsoft Graph java SDK.
public void countIf(String driveId, String itemId, String criteria, String range) throws IOException {
// Construct the CountIfPostRequestBody
CountIfPostRequestBody countIfPostRequestBody = new CountIfPostRequestBody();
countIfPostRequestBody.setCriteria(new UntypedString(criteria));
countIfPostRequestBody.setRange(new UntypedObject(Map.of("Address", new UntypedString(range))));
// Call the Graph API
RequestInformation postRequestInformation = graphServiceClient
.drives()
.byDriveId(driveId)
.items()
.byDriveItemId(itemId)
.workbook()
.functions()
.countIf()
.toPostRequestInformation(countIfPostRequestBody);
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
String requestId = batchRequestContent.addBatchRequestStep(postRequestInformation);
BatchResponseContent batchResponseContent =
graphServiceClient.getBatchRequestBuilder().post(batchRequestContent, null);
Response response = batchResponseContent.getResponseById(requestId);
}
Microsoft Graph API returns a valid batch response like this:
{
"responses": [
{
"id": "countIfRequest",
"status": 200,
"body": {
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.workbookFunctionResult",
"error": null,
"value": 174
}
}
]
}
SDK Version
6.39.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie in BatchResponseContent.java bei getResponseFromJsonObject, ungefähr in Zeile 199, und reproduzieren Sie die Batch-Antwort, die ein explizites null-Fehlerfeld enthält. Überprüfen Sie, dass der Antwortwert weiterhin erfolgreich verarbeitet wird und dass die IllegalStateException nicht mehr auftritt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100