Repository navigation
Conversation
GET /orgs/{org}/team-sync/groups pages with an opaque `page` token,
which Response.NextPageToken holds. The generated iterator waited for
Response.After instead, which this endpoint never sets, so it stopped
after the first page.
Add a page-token mode to gen-iterators for this method and regenerate.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4754 +/- ##
=======================================
Coverage 98.63% 98.63%
=======================================
Files 204 204
Lines 19165 19165
=======================================
Hits 18904 18904
Misses 261 261 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gmlewis
requested changes
Dec 4, 2026
gmlewis
left a comment
Collaborator
There was a problem hiding this comment.
No, I'm not happy with this PR because this issue can be fixed directly in the template only without adding more logic and more variables to gen-iterators.go.
I'm on my phone now but will provide more details later tonight.
Collaborator
|
I believe this one change is sufficient to solve this issue: diff --git a/github/gen-iterators.go b/github/gen-iterators.go
index 25f34fbb..90c3824e 100644
--- a/github/gen-iterators.go
+++ b/github/gen-iterators.go
@@ -721,10 +721,11 @@ func ({{.RecvVar}} *{{.RecvType}}) {{.IterMethod}}({{.Args}}) iter.Seq2[{{.Retur
{{.OptsName}}.ListCursorOptions.After = resp.After
{{.OptsName}}.ListOptions.Page = resp.NextPage
{{else if .UseListCursorOptions}}
- if resp.After == "" {
+ if resp.After == "" && resp.NextPageToken == "" {
break
}
{{.OptsName}}.ListCursorOptions.After = resp.After
+ {{.OptsName}}.ListCursorOptions.Page = resp.NextPageToken
{{else if .UseListOptions}}
if resp.NextPage == 0 {
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET /orgs/{org}/team-sync/groupspages with an opaquepagetoken, whichnewResponseputs inResponse.NextPageToken(the doc comment on that field names this method). The generatedListIDPGroupsInOrganizationIterwaits forResponse.Afterinstead, which this endpoint never sets, so it stops after the first page.This adds a page-token mode to
gen-iterators.gofor this one method (next to the existinguseCursorPaginationmap) and regenerates. The iterator now stops on an emptyNextPageTokenand setsopts.Pageto it. The generated test now serves?page=yoin theLinkheader; with master's iterator it fails (call 1 got 3 items; want 7).flowchart TD A[Iterator gets page 1 with a page token in Link] --> B{Next page} B -->|Before| C[Waits for after cursor and stops] B -->|After| D[Sends the page token and gets every page]Narrated recording, before then after (sound on):
evidence.mp4
The demo is a small program against a local fake server that pages groups the way the API does (
?page=<token>):Commands and output
master:
this branch:
Edge cases and unchanged behaviour checked (in the demo): a three-page token chain, a
qfilter kept on every page, a singleListIDPGroupsInOrganizationcall still returningNextPageToken, and theafter-cursorListGlobalSecurityAdvisoriesIterunchanged.Tests:
go test -run 'TestTeamsService_ListIDPGroupsInOrganization|Iter' ./githubpasses (284 tests);script/lint.shpasses (generated files up to date). I did not run the fullscript/test.sh.AI assistance: Claude Code found the bug and wrote the change, the test update and the demo.
🤖 Generated with Claude Code