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

Empty should collection is serialized improperly #8056

Closed
rr-media opened this issue Mar 19, 2024 · 0 comments · Fixed by #8090
Closed

Empty should collection is serialized improperly #8056

rr-media opened this issue Mar 19, 2024 · 0 comments · Fixed by #8090
Labels
8.x Relates to 8.x client version Area: Client Category: Bug

Comments

@rr-media
Copy link

rr-media commented Mar 19, 2024

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": []
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to 8.x client version Area: Client Category: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants