opensearch-project / opensearch-project/opensearch-java
[BUG] Client is unable to deserialize search response with profile API enabled
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?
When enabling .profile(true) on a search query, the opensearch-java client crashes with an UnexpectedJsonEventException: Unexpected JSON event 'START_ARRAY' instead of '[START_OBJECT, KEY_NAME]'.
This occurs because the OpenSearch server returns the fetch profile metrics as a JSON Array ("fetch": [ ... ]). However, the OpenAPI specification (and thus the auto-generated Java client) incorrectly defines fetch as a single object (FetchProfile) rather than a list of objects (List). Because of this mismatch, the Java deserializer expects a { but encounters a [ and immediately fails.
How can one reproduce the bug?
Execute a standard Search Request with profiling enabled.
What is the expected behavior?
The opensearch-java client should successfully deserialize the profile response without crashing.
What is your host/environment?
Java Client Version: opensearch-java v3.4.0 (tried on latest as well)
OpenSearch Server Version: 3.3
Do you have any screenshots?
"aggregations": [],
"fetch": [
{
"type": "fetch",
"description": "fetch",
"time_in_nanos": 177937,
"breakdown": {
"build_sub_phase_processors": 10339,
"build_sub_phase_processors_count": 1,
"create_stored_fields_visitor": 2642,
"create_stored_fields_visitor_count": 1,
"get_next_reader": 9412,
"get_next_reader_count": 2,
"load_source": 1732,
"load_source_count": 2,
"load_stored_fields": 151041,
"load_stored_fields_count": 2
},
"children": [
{
"type": "FetchSourcePhase",
"description": "FetchSourcePhase",
"time_in_nanos": 2771,
"breakdown": {
"process": 1509,
"process_count": 2,
"set_next_reader": 1262,
"set_next_reader_count": 2
}
}
]
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 the OpenAPI definition of the search profile response and the generated FetchProfile model in the opensearch-java client. Reproduce the issue by executing a standard Search Request with profiling enabled, then verify that the client's deserializer accepts the server's fetch array and completes without an UnexpectedJsonEventException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100