-
Notifications
You must be signed in to change notification settings - Fork 243
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
DisableUserResponse._DESERIALIZER should use emptyObject, not fixedValue #718
Comments
Hello, I would like to suggest my modification of the code that can solve this issue. Lines 62 to 63 in 7eb733f
From this java client code and according to henryptung, you can see the DisableUserResponse._DESERIALIZER is using This link also applies to 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, For // JsonpDeserializer.java
static <T> JsonpDeserializer<T> emptyObject(T value) {
return new JsonpDeserializerBase<T>(EnumSet.of(Event.START_OBJECT)) {
@Override
public T deserialize(JsonParser parser, JsonpMapper mapper, Event event) {
if (event == Event.VALUE_NULL) {
return null;
}
JsonpUtils.expectNextEvent(parser, Event.END_OBJECT);
return value;
}
};
} Unfortunately in java client, the response’s _DESERIALIZER is using Lines 62 to 63 in 7eb733f
Lines 63 to 64 in 7eb733f
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 I appreciate your time and input. Have a great day! |
I made #772 PR! PTAL when you have time 🙇♂️ |
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. |
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 |
Thank you so much for the detailed review! |
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 :) |
Java API client version
8.11.1
Java version
17
Elasticsearch Version
8.11.1
Problem description
The disable user endpoint actually returns an empty object, given server-side code here https://github.com/elastic/elasticsearch/blob/21f059166458978a5f3289686f1d218f0814c4ff/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java#L74.
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 usingJsonpDeserializer.emptyObject(T)
, which expects/consumes an empty object and then returns the singleton result value.Note: Think the same applies to
EnableUserResponse
andChangePasswordResponse
. Not sure whySimulateIndexTemplateResponse
is using.fixedValue
, given the server-sideSimulateIndexTemplateResponse
actually contains JSON content/data, but fairly confident all uses ofJsonpDeserializer.fixedValue
are suspect.The text was updated successfully, but these errors were encountered: