Skip to content

[BUG] Client is unable to deserialize search response with profile API enabled #1965

@mcv922

Description

@mcv922

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
                                }
                            }
                        ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions