opensearch-project / opensearch-project/opensearch-java
[BUG] MissingRequiredPropertyException: Missing required property 'ResourceStats.average' when polling _tasks API
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
What is the bug?
The ResourceStats schema in spec/schemas/_common.yaml of the opensearch-api-specification marks average, max, min, thread_info, and total as all required. However, the _tasks API on OpenSearch 1.3 only returns total in the resource_stats block when a task is in-flight.
Per the compatibility matrix, opensearch-java 3.x supports OpenSearch 1.x-3.x, so the spec should reflect what 1.x actually returns.
This causes the opensearch-java 3.8.0 client to throw:
org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'ResourceStats.average'
at org.opensearch.client.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:90)
at org.opensearch.client.opensearch._types.ResourceStats.<init>(ResourceStats.java:82)
at org.opensearch.client.opensearch._types.ResourceStats$Builder.build(ResourceStats.java:302)
at org.opensearch.client.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:92)
How can one reproduce the bug?
1. Index test documents (100k+):
POST /test-index/_bulk
{"index":{"_id":"1"}}
{"date":"2020-01-01T00:00:00Z","status":"OPEN"}
{"index":{"_id":"2"}}
{"date":"2020-01-01T00:00:00Z","status":"OPEN"}
... (repeat to 100k+ documents)
2. Submit async delete-by-query:
POST /test-index/_delete_by_query?wait_for_completion=false&conflicts=proceed
{
"query": {
"range": {
"date": {
"lt": "now-6M/d"
}
}
}
}
Response:
{
"task": "nodeId:1234567"
}
3. Poll the task while it's still running:
GET /_tasks/nodeId:1234567
In-flight response (before task completes):
{
"completed": false,
"task": {
"node": "nodeId",
"id": 1234567,
"type": "transport",
"action": "indices:data/write/delete/byquery",
"status": {
"total": 100000,
"updated": 0,
"created": 0,
"deleted": 11000,
"batches": 12,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1.0,
"throttled_until_millis": 0
},
"description": "delete-by-query [test-index]",
"start_time_in_millis": 1781528541973,
"running_time_in_nanos": 587603829,
"cancellable": true,
"cancelled": false,
"headers": {},
"resource_stats": {
"total": {
"cpu_time_in_nanos": 0,
"memory_in_bytes": 0
}
}
}
}
Note: resource_stats contains only total. The fields average, max, min, and thread_info are absent. The opensearch-java 3.8.0 client fails to deserialize this response because ResourceStats marks all five fields as required.
4. After task completes, resource_stats is no longer present in the response, which is why this only surfaces when polling in-flight tasks with large enough data volumes for the task to take seconds.
Environment
- opensearch-java client version: 3.8.0
- OpenSearch server: 1.3
- Java version: 17
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with spec/schemas/_common.yaml and compare the ResourceStats requirements with the OpenSearch 1.3 _tasks response shown here. Check the compatibility matrix before changing the specification, then verify that an in-flight response containing only resource_stats.total can be handled and that existing client tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100