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

Indicies.Get call fails to deserialize ICollections properly in the IndexRequest #8034

Closed
baveryt opened this issue Feb 1, 2024 · 3 comments · Fixed by elastic/elastic-transport-net#108 or #8134
Labels
8.x Relates to 8.x client version Area: Transport Category: Bug

Comments

@baveryt
Copy link

baveryt commented Feb 1, 2024

Elastic.Clients.Elasticsearch version: 8.11

Elasticsearch version: 8.8

.NET runtime version: 8.0

Operating system version: Osx

Description of the problem including expected versus actual behavior:
When making calls to Indicies.Get and setting the Features or ExpandWildcards on the GetIndexRequest object the ICollections are not getting parsed properly for the underlying API call. Looking at the stack trace you'll see something like: Invalid Elasticsearch response built from a unsuccessful (400) low level call on GET: /%2A?features=System.Collections.ObjectModel.Collection%601%5BElastic.Clients.Elasticsearch.IndexManagement.Feature%5D\n

Steps to reproduce:

  1. Make a call to the Indicies.Get setting either the features or expandwildcards option

Expected behavior
For the features it should expand out the collections properly [aliases] in this case.

@baveryt baveryt added the 8.x Relates to 8.x client version label Feb 1, 2024
@flobernd
Copy link
Member

flobernd commented Feb 5, 2024

Hey @baveryt, could you please include the JSON payloads for the request (and response, if possible)? They should be included in the exception after calling DisableDirectStreaming() on your ElasticSearchSettings instance.

@baveryt
Copy link
Author

baveryt commented Feb 6, 2024

@flobernd - The call actually does not throw an exception, it just reports that it was an invalid request. I'll include what I can here
Original Code:

var gir = new GetIndexRequest("search_*") {
      Features = new List<Feature>() {
          Feature.Aliases
      }
  };
  var response = Client.Indices.Get(gir);

The response reports back IsValidResponse = false. The Debug information shows:

"Invalid Elasticsearch response built from a unsuccessful (400) low level call on GET: /search_%2A?features=System.Collections.Generic.List%601%5BElastic.Clients.Elasticsearch.IndexManagement.Feature%5D 
 Exception: Request failed to execute. Call: Status code 400 from: GET /search_%2A?features=System.Collections.Generic.List%601%5BElastic.Clients.Elasticsearch.IndexManagement.Feature%5D. ServerError: Type: illegal_argument_exception Reason: \"Invalid features specified [System.Collections.Generic.List`1[Elastic.Clients.Elasticsearch.IndexManagement.Feature]]\"

# Audit trail of this API call: 
 - [1] BadResponse: Node: https://localhost:9200/ Took: 00:00:00.0049380
# OriginalException: Elastic.Transport.TransportException: Request failed to execute. Call: Status code 400 from: GET /search_%2A?features=System.Collections.Generic.List%601%5BElastic.Clients.Elasticsearch.IndexManagement.Feature%5D. ServerError: Type: illegal_argument_exception Reason: \"Invalid features specified [System.Collections.Generic....

The ElasticsearchServerError shows:

"Invalid features specified [System.Collections.Generic.List`1[Elastic.Clients.Elasticsearch.IndexManagement.Feature]]"

It's all pointing to the Features list couldn't be converted properly, it should have built the request like: GET /search_%2A?features=aliases

You will also see a similar problem if you do something similar to the ExpandWildcards property.

@flobernd
Copy link
Member

Thanks for the additional details! It indeed seems like building the query argument fails for some cases when the argument is a collection.

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: Transport Category: Bug
Projects
None yet
2 participants