-
Notifications
You must be signed in to change notification settings - Fork 559
Add more results to GitHub App repository listing #1941
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
base: develop
Are you sure you want to change the base?
Conversation
…ve more results (100) per page
WalkthroughThe change updates the GitHub repository listing logic in the Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Implemented pagination options in GithubAppCallbackPage
to increase repository listing limit from 30 to 100, addressing immediate truncation issues in GitHub App repository registration.
- Modified
client.Apps.ListRepos
call in/backend/controllers/github.go
to usegithub.ListOptions{Page: 1, PerPage: 100}
- Current fix is temporary and needs enhancement to handle pagination for >100 repositories
- Consider adding a warning or limit indicator when approaching 100 repository limit
- Recommend implementing proper pagination handling in future updates to support unlimited repositories
💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
opt := &github.ListOptions{Page: 1, PerPage: 100} | ||
listRepos, _, err := client.Apps.ListRepos(context.Background(), opt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This only retrieves the first 100 repositories. Need to implement pagination to handle orgs with >100 repos.
opt := &github.ListOptions{Page: 1, PerPage: 100} | |
listRepos, _, err := client.Apps.ListRepos(context.Background(), opt) | |
opt := &github.ListOptions{Page: 1, PerPage: 100} | |
var repos []*github.Repository | |
for { | |
listRepos, resp, err := client.Apps.ListRepos(context.Background(), opt) | |
if err != nil { | |
slog.Error("Failed to list existing repositories", | |
"installationId", installationId64, | |
"page", opt.Page, | |
"error", err, | |
) | |
c.String(http.StatusInternalServerError, "Failed to list existing repos: %v", err) | |
return | |
} | |
repos = append(repos, listRepos.Repositories...) | |
if resp.NextPage == 0 { | |
break | |
} | |
opt.Page = resp.NextPage | |
} |
Problem
We noticed that when 30 repositories are registered with the GitHub App, adding a 31st repository causes one of the existing ones (often the latest) to be removed.
https://diggertalk.slack.com/archives/C01DVJRK6CX/p1745923260568589
Root cause
By default, the GitHub API returns a limited number of results per request (usually 30). Since the call to
client.Apps.ListRepos
did not explicitly handle pagination, we were unintentionally working with a truncated list of repositories.Quick fix
We now explicitly provide pagination options using
github.ListOptions{Page: 1, PerPage: 100}
to ensure the API returns up to 100 repositories.This is a temporary fix, as the implementation should ideally retrieve all Git repositories.
Summary by CodeRabbit