Skip to content

Commit d50c035

Browse files
add back improved error message
1 parent 961b69d commit d50c035

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/backend/src/ee/accountPermissionSyncer.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,21 @@ export class AccountPermissionSyncer {
191191
// @note: we only care about the private repos since we don't need to build a mapping
192192
// for public repos.
193193
// @see: packages/web/src/prisma.ts
194-
const githubRepos = await getReposForAuthenticatedUser(/* visibility = */ 'private', octokit);
194+
let githubRepos;
195+
try {
196+
githubRepos = await getReposForAuthenticatedUser(/* visibility = */ 'private', octokit);
197+
} catch (error) {
198+
if (error && typeof error === 'object' && 'status' in error) {
199+
const status = (error as { status: number }).status;
200+
if (status === 401 || status === 403) {
201+
throw new Error(
202+
`GitHub API returned ${status} error. Your token may have expired or lacks the required permissions. ` +
203+
`Please re-authorize with GitHub to grant the necessary access.`
204+
);
205+
}
206+
}
207+
throw error;
208+
}
195209
const gitHubRepoIds = githubRepos.map(repo => repo.id.toString());
196210

197211
const repos = await this.db.repo.findMany({

0 commit comments

Comments
 (0)