Skip to content

Empty should collection is serialized improperly #8056

Closed
@rr-media

Description

@rr-media

Elastic.Clients.Elasticsearch version: 8.12.0

Elasticsearch version: 8.3.1

.NET runtime version: 8.0

Operating system version: MacOs Sonoma

.Should method with empty collection of actions generates incorrect json in the request to ES which leads to 400 response. NEST worked properly in the same case and sent an empty array

Steps to reproduce:
1.
Do something like this

var response = await this.Client8.SearchAsync<Contact>(
       sd => sd.Routing($"{contact.OrgId}").Index("contacts-t").Query(q => q.Bool(b => b.Should(Array.Empty<Action<QueryDescriptor<ContactProjection>>>()))));

The following body will be generated

# Request:
{
  "query": {
    "bool": {
      "should": 
    }
  }
}
  1. The response will fail with 400: Unexpected character ('}' (code 125)): expected a value

Expected behavior
The following request should be sent

# Request:
{
  "query": {
    "bool": {
      "should": []
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions