order should be preserved with batchCheck API
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 89
- Forks
- 26
- Avg merge
- 1h 22m
- Merged PRs (30d)
- 10
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 https://github.com/openfga/js-sdk/pull/233
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at client.ts around lines 711-713, where the issue says the JS SDK adds correlation IDs while preparing batchCheck arguments. Review the behavior described in pull request #233 and verify that batchCheck results preserve the input array order. Done means the returned array consistently matches the order of the supplied checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100