Skip to content

fix: new project widget broken if 'null' item(s) received from gh api #11630

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

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion components/server/ee/src/prebuilds/github-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ export class GitHubService extends RepositoryService {
@inject(TokenService) protected tokenService: TokenService;
@inject(GithubContextParser) protected githubContextParser: GithubContextParser;

// TODO: consider refactoring this to either use GH Search API w/ typeahead search only OR
// return results in a stream, appending pages as being fetched (via callback below) OR
// simply use octokit.request w/ basic paginated api funcs (return # of pages + return a single page),
// so the UI can remain interactive vs. currently frozen for 5-10+ mins until all pages are fetched.
async getRepositoriesForAutomatedPrebuilds(user: User): Promise<ProviderRepository[]> {
const octokit = await this.githubApi.create(user);
const repositories = await octokit.paginate(
octokit.repos.listForAuthenticatedUser,
{ per_page: 100 },
(response) =>
response.data
.filter((r) => !!r.permissions?.admin)
// On very large GH Enterprise (3.3.9) instances, items can be null
.filter((r) => !!r?.permissions?.admin)
.map((r) => {
return <ProviderRepository>{
name: r.name,
Expand Down