Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Listing tasks without grouping fails with: Unexpected JSON event 'START_ARRAY' instead of '[START_OBJECT]' #1326

Open
fs-chris opened this issue Nov 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fs-chris
Copy link
Contributor

What is the bug?

When trying to get tasks as list with group_by=none option the response cannot be parsed.
The following exception is thrown

UnexpectedJsonEventException: Unexpected JSON event 'START_ARRAY' instead of '[START_OBJECT]'
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.JsonpUtils.ensureAccepts(JsonpUtils.java:116)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:86)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:81)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:185)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:146)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:87)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:91)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:55)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.transport.rest_client.RestClientTransport.decodeResponse(RestClientTransport.java:360)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:326)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:148)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.opensearch.tasks.OpenSearchTasksClient.list(OpenSearchTasksClient.java:153)
	at deployment.njams-6.1.0-SNAPSHOT.war//org.opensearch.client.opensearch.tasks.OpenSearchTasksClient.list(OpenSearchTasksClient.java:166)

A sample request/response looks like

GET _tasks?group_by=none
{ 
  "tasks": [ 
    { 
      "node": "a8R07eoVQxqZhrN8WWZBUQ",
      "id": 6616,
      "type": "transport",
      "action": "cluster:monitor/tasks/lists",
      "start_time_in_millis": 1732530485437,
      "running_time_in_nanos": 337735,
      "cancellable": false,
      "cancelled": false,
      "headers": { 

      }
    },
    { 
      "node": "a8R07eoVQxqZhrN8WWZBUQ",
      "id": 6617,
      "type": "direct",
      "action": "cluster:monitor/tasks/lists[n]",
      "start_time_in_millis": 1732530485437,
      "running_time_in_nanos": 114967,
      "cancellable": false,
      "cancelled": false,
      "parent_task_id": "a8R07eoVQxqZhrN8WWZBUQ:6616",
      "headers": { 

      }
    }
  ]
}

How can one reproduce the bug?

Build and execute a request like this: client.tasks().list(t -> t.groupBy(GroupBy.None))

What is the expected behavior?

The response should be parsed into a ListResponse

What is your host/environment?

Java Client: 2.18.0
OpenSearch server: 2.18.0 (Docker)

Do you have any screenshots?

n/a

Do you have any additional context?

n/a

@fs-chris fs-chris added bug Something isn't working untriaged labels Nov 25, 2024
@Xtansia Xtansia removed the untriaged label Nov 26, 2024
@Xtansia
Copy link
Collaborator

Xtansia commented Nov 26, 2024

This issue has already been fixed for the future 3.0.0 release, but it is not directly backwards compatible so hasn't been backported for 2.x yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants