Describe the bug?
func (res *APIResponse) Next (v interface{}) (*APIResponse, error) doesn't accepts ctx any more (since v2?) and opting use client's ctx, this means the code like this:
users, resp, err := client.UserAPI.ListUsers(ctx, query)
// Do something with your users until you run out of users to iterate.
for resp.HasNextPage() {
var nextUserSet []okta.User
resp, err = resp.Next(&user2)
...
}
can't be cancelled (or timed-out) because resp building new request that uses another context.
I understand the client's context is used for auth, but it should be copied at most, not override the newer ctx provided in request's ctor
another issue using the old context is OTEL/spans which then new spans are not created in the current context
What is expected to happen?
calling cancel() on ctx stops the paging/loop
What is the actual behavior?
nothing happens, the original request context is ignored after the first execution ,
the migration guide of v6 mention the new pager (req.After()) but it isn't complete:
- No "get next token" on resp,
- After (or a "next page" method) should also consider an updated
Limit from the Next link
- Not all paged requests implement
After method (e.g. ApiListUserGroupsRequest, or ListAssignedRolesForUser and probably more)
Reproduction Steps?
ctx, canel := context.WithCancel(context.Background())
users, resp, err := oktaCli.UserAPI.ListUsers(ctx).Limit(1).Execute()
if err != nil {
panic(err)
}
readUsers(users)
for resp.HasNextPage() {
var newResp okta.APIResponse
reps, err = resp.After(&newResp)
if err != nil {
panic(err)
}
readUsers(users)
cancel()
}
Additional Information?
No response
Golang Version
go version go1.25.11 linux/amd64
SDK Version
v6.1.6
OS version
No response
Describe the bug?
func (res *APIResponse) Next (v interface{}) (*APIResponse, error)doesn't accepts ctx any more (since v2?) and opting use client's ctx, this means the code like this:can't be cancelled (or timed-out) because resp building new request that uses another context.
I understand the client's context is used for auth, but it should be copied at most, not override the newer ctx provided in request's ctor
another issue using the old context is OTEL/spans which then new spans are not created in the current context
What is expected to happen?
calling
cancel()on ctx stops the paging/loopWhat is the actual behavior?
nothing happens, the original request context is ignored after the first execution ,
the migration guide of v6 mention the new pager (req.After()) but it isn't complete:
Limitfrom the Next linkAftermethod (e.g.ApiListUserGroupsRequest, orListAssignedRolesForUserand probably more)Reproduction Steps?
Additional Information?
No response
Golang Version
go version go1.25.11 linux/amd64
SDK Version
v6.1.6
OS version
No response