You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DisableUserResponse._DESERIALIZER should use emptyObject, not fixedValue #718
However, the Java client uses JsonpDeserializer.fixedValue(T) here, which expects no JSON content at all (i.e. accepts no JSON events at all). Rather, it should be using JsonpDeserializer.emptyObject(T), which expects/consumes an empty object and then returns the singleton result value.
Note: Think the same applies to EnableUserResponse and ChangePasswordResponse. Not sure why SimulateIndexTemplateResponse is using .fixedValue, given the server-side SimulateIndexTemplateResponse actually contains JSON content/data, but fairly confident all uses of JsonpDeserializer.fixedValue are suspect.
From this java client code and according to henryptung, you can see the DisableUserResponse._DESERIALIZER is using JsonpDeserializer.fixedValue(T), which I propose changing it to using JsonpDeserializer.emptyObject(T), due to the fact that the disable user endpoint returns an empty object given the link below.
As you can see, ChangePasswordResponse should also be using .emptyObject(T), since it actually returns an emptyObject from the server-side.
For SimulateIndexTemplateResponse server-side code, it might not always return an empty object, but there's a possibility of returning one. Therefore, I find it necessary for the response's _DESERIALIZER to use .emptyObject(T) as well, since the emptyObject function from JsonpDeserializer looks like this.
Therefore, I made a PR that satisfies the modification offers that I mentioned in this comment.
I changed four response’s _DESERIALIZER to use emptyObject(T). Also, the ./gradlew check was successful after my changes. Can you take a look at it and notify me if there is anything more to reflect or consider?
I appreciate your time and input. Have a great day!
Hello! Thank you for your time and your interest in the java client :) unfortunately we cannot accept PRs that modify generated files, because they would just be overwritten when the code gets generated again. In this particular case, to change this code we would have to modify the java client generator, which is private. I'll keep your PR open because that's probably the result we want to end up with! Thanks again
Hello! I've fixed this issue in the generator and pushed the new code to the java client, you can see it for example in the EnableUserResponse class. Thanks again for providing the original fix :)
Activity
shinsj4653 commentedon Mar 30, 2024
Hello, I would like to suggest my modification of the code that can solve this issue.
elasticsearch-java/java-client/src/main/java/co/elastic/clients/elasticsearch/security/DisableUserResponse.java
Lines 62 to 63 in 7eb733f
From this java client code and according to henryptung, you can see the DisableUserResponse._DESERIALIZER is using
JsonpDeserializer.fixedValue(T), which I propose changing it to usingJsonpDeserializer.emptyObject(T), due to the fact that the disable user endpoint returns an empty object given the link below.This link also applies to
EnableUserResponse, since RestSetEnabledAction handles the enable user endpoint as well.I’m assuming that when the code is generated from the Elasticsearch API specification, it is being set to use only the fixedValue function.
Also, I searched for the other server-side codes that returns emptyObject. Here are the codes that I found.
As you can see,
ChangePasswordResponseshould also be using.emptyObject(T), since it actually returns an emptyObject from the server-side.For
SimulateIndexTemplateResponseserver-side code, it might not always return an empty object, but there's a possibility of returning one. Therefore, I find it necessary for the response's _DESERIALIZER to use.emptyObject(T)as well, since the emptyObject function fromJsonpDeserializerlooks like this.Unfortunately in java client, the response’s _DESERIALIZER is using
fixedValue(T). You can notice this in these code links.elasticsearch-java/java-client/src/main/java/co/elastic/clients/elasticsearch/security/EnableUserResponse.java
Lines 62 to 63 in 7eb733f
elasticsearch-java/java-client-serverless/src/main/java/co/elastic/clients/elasticsearch/indices/SimulateIndexTemplateResponse.java
Lines 63 to 64 in 7eb733f
elasticsearch-java/java-client/src/main/java/co/elastic/clients/elasticsearch/security/ChangePasswordResponse.java
Lines 63 to 64 in 7eb733f
Therefore, I made a PR that satisfies the modification offers that I mentioned in this comment.
I changed four response’s _DESERIALIZER to use
emptyObject(T). Also, the./gradlew checkwas successful after my changes. Can you take a look at it and notify me if there is anything more to reflect or consider?I appreciate your time and input. Have a great day!
shinsj4653 commentedon Mar 30, 2024
I made #772 PR! PTAL when you have time 🙇♂️
shinsj4653 commentedon Apr 15, 2024
Hello @l-trotta. I would like to request a review for my PR and let me know if it is in the right direction to solve the issue.
l-trotta commentedon Apr 16, 2024
Hello! Thank you for your time and your interest in the java client :) unfortunately we cannot accept PRs that modify generated files, because they would just be overwritten when the code gets generated again. In this particular case, to change this code we would have to modify the java client generator, which is private. I'll keep your PR open because that's probably the result we want to end up with! Thanks again
shinsj4653 commentedon Apr 16, 2024
Thank you so much for the detailed review!
I'll continue using the Elasticsearch client and open some issues if I run into any! :) Have a great day!
l-trotta commentedon May 30, 2024
Hello! I've fixed this issue in the generator and pushed the new code to the java client, you can see it for example in the EnableUserResponse class. Thanks again for providing the original fix :)