okta / okta-sdk-golang

A Golang SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.
https://github.com/okta/okta-sdk-golang
Other
173 stars 143 forks source link

List Of Groups API is not working with pagination #397

Closed CypagoTest closed 9 months ago

CypagoTest commented 1 year ago

Describe the bug?

im using Golang Okta SDK , im collecting users, roles, apps, and groups from okta. all API endpoints looks good, but Group.ListGroups endpoint is not working with pagination. once i get all groups from Okta, resp.HasNextPage() return me not nil value, and i got infinitive loop and as a result run time error.

What is expected to happen?

Once i received all groups from Okta, i want to get resp.HasNextPage() false, and break the collection.

What is the actual behavior?

for loop collection stacked with run time error, as resp.HasNextPage() return true every time, even if we do not more groups to collect.

Reproduction Steps?

groups, resp, err := client.Group.ListGroups(ctx, queryParams)
    if err != nil {
        logger.Err(err).Msg("Failed to get all groups from Okta")
                 return
    }
    for resp != nil && resp.HasNextPage() {
        curGroups := make([]*okta.Group, 0, recommendedResultsPerQuery)
        resp, err = resp.Next(ctx, &curGroups)
        if err != nil {
            logger.Warn().Msgf("Groups pagination failed. Err: '%v'", err.Error())
            break
        }
        groups = append(groups, curGroups...)
    }

Additional Information?

No response

Golang Version

go version go1.20.3 darwin/arm64

SDK Version

github.com/okta/okta-sdk-golang/v2/okta

OS version

Mac , but for Linux the same.

CypagoTest commented 1 year ago

@monde @bogdanprodan-okta @duytiennguyen-okta @emanor-okta @bretterer Guys , can you please investigate this issue? it cost us a lot.

BR, Cypago

monde commented 1 year ago

There is a bug in the Okta API on the groups endpoint where pagination appears to be broken. I'm running it down internally at Okta with the responsible feature team. okta-sdk-golang is down stream of the API.

monde commented 1 year ago

Okta internal reference: OKTA-633507

monde commented 1 year ago

This bug is only exhibited if the last group when paginating is the Admin Group. I don't believe everyone would necessarily experience this bug.

github-actions[bot] commented 1 year ago

This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale label.

github-actions[bot] commented 12 months ago

This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale label.

monde commented 11 months ago

Okta will be deploying the fix for this issue into production on October 10th Okta internal reference: https://oktainc.atlassian.net/browse/OKTA-633507

MytsYurii commented 5 months ago

@monde is this issue fixed, can we collect the groups with the pagination without any problems?

duytiennguyen-okta commented 5 months ago

Yes that should be fixed