Skip to content

HasContinuationToken() methods return true whereas there is no more page #38

@le-yams

Description

@le-yams

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.

  1. Initialize OpenFgaClient to point an openfga instance with N stores
  2. invoke the ListStores()method with a page size > N
  3. the response HasContinuationToken() should return false but it actually returns true

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

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions