-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Hello there,
Description
When using "paginable" methods, the HasContinuationToken() methods return true whereas there is no more page.
I expect the HasContinuationToken() method to return false in such cases.
As the openfga "paginable" endpoints always returns the continuation_token field (with an empty string value if there is no more page), the ContinuationToken response field is never nil (and so the HasContinuationToken() implementation always retrurn true).
Version of SDK
v0.2.2
Version of OpenFGA
v1.1.1
Reproduction
This issue can be reproduced consistently invoking any method querying an openfga "paginable" endpoint.
Here is an example using the ListStores method.
- Initialize OpenFgaClient to point an openfga instance with N stores
- invoke the
ListStores()method with a page size > N - the response
HasContinuationToken()should returnfalsebut it actually returnstrue
Sample Code that Produces the Issue
Another example relying on the continuation token to do something with all stores that creates an infinite loop because of the HasContinuationToken() method always returning true.
response, err := fgaClient.ListStores(context.Background()).Options(options).Execute()
if err != nil {
return "", err
}
doSomethingWith(response.GetStores())
// infinite loop here because HasContinuationToken() always return true
for response.HasContinuationToken() {
options.ContinuationToken = response.ContinuationToken
response, err = fgaClient.ListStores(context.Background()).Options(options).Execute()
if err != nil {
return "", err
}
doSomethingWith(response.GetStores())
}Expected behavior
The HasContinuationToken() method (on any response type) should return false if the response continuation_token field is an empty string
Metadata
Metadata
Assignees
Labels
Type
Projects
Status