-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ExpandWildcards option is not correctly serialized on Delete indices request #7823
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
Comments
The root of the problem is in the library elastic-transport-net, the corresponding pull request is here: There is also a different problem. Even if this serialization problem is fixed in elastic-transport-net, the other problem will arise. The ExpandWildcard enum values have a capital first letter in its enum values, but elastic search requires values for the parameter "expand_wildcards" to be all lowercase. For example, for expand_wildcards=All the elasticsearch also will return 400 bad request. |
The current workaround is to use the more low level code: var parameters = new DefaultRequestParameters();
parameters.QueryString.Add("expand_wildcards", "all");
var response = _EsClient.Transport.Delete<DeleteIndexResponse>("/rules%2A", null, parameters); |
Capitalization good to me: elasticsearch-net/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs Lines 333 to 361 in b7b9e1e
|
Did you test it? When converting to JSON the code indeed uses this EnumMemberAttribute, but when converting to an URL query string parameter -- then a simple .ToString() method is called on the enum value (first the IEnumerable branch will be called after my patch and then for each member of the collection ResolveUrlParameterOrDefault will be called. The latter just will call .ToString()). And .ToString() doesn't respect the EnumMemberAttribute. public static string CreateString(object value, ITransportConfiguration settings)
{
switch (value)
{
case null: return null;
case string s: return s;
case string[] ss: return string.Join(",", ss);
case Enum e: return e.GetStringValue();
case bool b: return b ? "true" : "false";
case DateTimeOffset offset: return offset.ToString("o");
case IEnumerable<object> pns:
return string.Join(",", pns.Select(o => ResolveUrlParameterOrDefault(o, settings)));
case TimeSpan timeSpan: return timeSpan.ToTimeUnit();
default:
return ResolveUrlParameterOrDefault(value, settings);
}
}
private static string ResolveUrlParameterOrDefault(object value, ITransportConfiguration settings) =>
value is IUrlParameter urlParam ? urlParam.GetString(settings) : value.ToString(); |
Elastic.Clients.Elasticsearch version: 8.1.2
Elasticsearch version: 8.8.2
.NET runtime version: .NET 6
Operating system version: Windows 10 Enterprise
Description of the problem including expected versus actual behavior:
When trying to delete indices with the wildcard with the following code:
The server returns unsuccesful response:
obviously because the library generates incorrect query string parameter "expand_wildcards", which has to be a comma-separated string of any of "all,open,close,hidden,none" values, but instead the "Elastic.Clients.Elasticsearch.ExpandWildcard" string is added to this parameter.
Steps to reproduce:
Expected behavior
Succesful return code (and the query string with the correct "expand_wildcards" parameter).
Provide
DebugInformation
(if relevant):The text was updated successfully, but these errors were encountered: