-
Notifications
You must be signed in to change notification settings - Fork 26
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
HasContinuationToken() methods return true whereas there is no more page #38
Comments
Hello @le-yams , thank you for raising this issue. In order to check whether you are done reading, you not only need to check whether has continuation token is true, but also check against whether it is the same as previous continuation token. Thus, you will need to have something like continuationToken := ""
options.ContinuationToken = &continuationToken
response, err := fgaClient.ListStores(context.Background()).Options(options).Execute()
if err != nil {
return "", err
}
doSomethingWith(response.GetStores())
// check whether the continuation token is the same as previous
for {
options.ContinuationToken = &continuationToken
response, err = fgaClient.ListStores(context.Background()).Options(options).Execute()
if err != nil {
return "", err
}
doSomethingWith(response.GetStores())
if !response.HasContinuationToken() || *response.ContinuationToken == continuationToken {
break
}
continuationToken = *response.ContinuationToken
} Let me know if you need further clarification. Thank you. |
Hello @adriantam ,
Thank you for pointing that out 🙂. Could you clarify the case where the returned continuation token would be the same as the one specified in the request? Is the pagination system specified somewhere (I didn't find it in the documentation)? Thank you for your help. |
Hello @le-yams , thank you for your notes. You are correct in that empty string means the last page (sorry that we were mistaken). With that in mind, you should have something like this: continuationToken := ""
options.ContinuationToken = &continuationToken
response, err := fgaClient.ListStores(context.Background()).Options(options).Execute()
if err != nil {
return "", err
}
doSomethingWith(response.GetStores())
// check whether the continuation token is the same as previous
for {
options.ContinuationToken = &continuationToken
response, err = fgaClient.ListStores(context.Background()).Options(options).Execute()
if err != nil {
return "", err
}
doSomethingWith(response.GetStores())
if !response.HasContinuationToken() || *response.ContinuationToken == "" {
break
}
continuationToken = *response.ContinuationToken
} |
Hello there,
Description
When using "paginable" methods, the
HasContinuationToken()
methods returntrue
whereas there is no more page.I expect the
HasContinuationToken()
method to returnfalse
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), theContinuationToken
response field is nevernil
(and so the HasContinuationToken() implementation always retrurntrue
).Version of SDK
Version of OpenFGA
Reproduction
This issue can be reproduced consistently invoking any method querying an openfga "paginable" endpoint.
Here is an example using the
ListStores
method.ListStores()
method with a page size > NHasContinuationToken()
should returnfalse
but 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
.Expected behavior
The
HasContinuationToken()
method (on any response type) should returnfalse
if the responsecontinuation_token
field is an empty stringThe text was updated successfully, but these errors were encountered: