-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Description
the batchCheck HTTP API accepts an array of checks, and requires that each check contains a correlation ID. As a convenience, the JS SDK will add these correlationIDs for you, modifying the arguments here out-parameter style.
Unlike the batchCheck HTTP API which returns a Map, the batchCheck JS SDK returns an array for this method. This can be confusing for consumers of the JS SDK, as they may not realize that order is not being preserved, or that the arguments are being mutated.
I propose that the JS SDK preserves the array order to make it easier on consumers, and also reduce the likelihood of errors.
Alternatively, the SDK should change its response to be a map, and possibly drop the convenience of auto-adding correlationIDs, in order to ensure consumers correctly use the method.
Version of SDK
v0.9.0, the current latest
Version of OpenFGA
v1.8.13, the current latest
Reproduction
Detail the steps taken to reproduce this error, what was expected, and whether this issue can be reproduced consistently or if it is intermittent.
- Initialize OpenFgaClient with openfga_sdk.ClientConfiguration parameter api_host=127.0.0.1, credentials method client_credentials
- Invoke method read_authorization_models
- See exception thrown
Sample Code the Produces Issues
const response = await openFgaClient.batchCheck(
{
checks: [
...[..."abcdefghijklmnopqrstuvwxyz"].map((letter) => ({
user: `user:${letter}`,
relation: "access",
object: "feature:foo",
})),
],
}
);The above code returns the 26 checks in an arbitrary order.
I provided a fix in #233
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status