microsoftgraph / microsoftgraph/msgraph-sdk-java
BatchResponseContent fails when processing "error": null in batch responses
オープン
まだ誰も着手していません。
status:waiting-for-triage
type:bug
- 主要言語
- Java
- スター
- 444
- フォーク
- 154
- 平均マージ
- 18時間 28分
- マージ済み PR(30日)
- 4
説明
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_
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
BatchResponseContent.java の getResponseFromJsonObject、199 行目付近から始め、明示的な null のエラーフィールドを含むバッチレスポンスを再現します。レスポンス値が引き続き正常に処理され、IllegalStateException が発生しなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- api
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100