-
Notifications
You must be signed in to change notification settings - Fork 42
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
java-sdk calling the server without content when submitting empty deletes and writes #307
Conversation
a02af72
to
95e9c96
Compare
config/clients/java/template/client-ClientWriteResponse.java.mustache
Outdated
Show resolved
Hide resolved
Thanks for the PR @srose! Apologies if the issue was worded vaguely. The intention is not to short-circuit when the field is not provided, instead it's to ensure the field is not sent to the API if it were an empty array. This may currently already be the case, but we'd like to add tests specifically for this, and if it's not the case, fix it so that they're no longer being sent.
|
@rhamzeh, @jimmyjames thank you for the clarification, gave it a try with a test and at least the test failed without modification. Please have a look and decide if my changes are useful. |
ok, I spent a little bit of time looking at this, and tl;dr I think this SDK is already not actually sending the If we look at Since the default value for those fields will be For example, this test includes the logic from @Test
public void jsonTest() throws Exception {
List<ClientTupleKeyWithoutCondition> tupleDeletes = List.of(new ClientTupleKeyWithoutCondition()
._object(DEFAULT_OBJECT)
.relation(DEFAULT_RELATION)
.user(DEFAULT_USER));
var request = new ClientWriteRequest().writes(Collections.emptyList()).deletes(tupleDeletes);
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
WriteRequest body = new WriteRequest();
var writeTuples = request.getWrites();
if (writeTuples != null && !writeTuples.isEmpty()) {
body.writes(ClientTupleKey.asWriteRequestWrites(writeTuples));
}
var deleteTuples = request.getDeletes();
if (deleteTuples != null && !deleteTuples.isEmpty()) {
body.deletes(ClientTupleKeyWithoutCondition.asWriteRequestDeletes(deleteTuples));
}
System.out.println(mapper.writeValueAsString(body));
} Produces (notice no {"deletes":{"tuple_keys":[{"user":"user:81684243-9356-4421-8fbf-a4f8d36aa31b","relation":"reader","object":"document:budget"}]}} All that said, the added test in your PR uncovered a different potential issue 😆. After building the transactions, we call Let me think on it a bit but I think I'll create a new issue for the Thanks again for your contribution and patience as we dig into it more! |
Also, for completeness to @rhamzeh's point, I believe there are tests that cover the original reported issue cases; |
@jimmyjames thank you for your support, i think you are right on everything you wrote. I think I will try to rework the code with the IndexOutOfBounds section. Its fixed now, but I can think of an improvement. |
…nd reads are sent from openfga/sdk-generator#307
Open for this PR:
Description
For the Java SDK make passing empty deletes and empty writes to the write command perform a server call without content
References
Part of #299 and #306
SDK PRs to come shortly
Review Checklist
main