Skip to content

Commit 050942f

Browse files
Don't be so chatty when hasReadAccess throws (#20400)
1 parent cc6e7a0 commit 050942f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

components/server/src/bitbucket/bitbucket-repository-provider.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,14 @@ export class BitbucketRepositoryProvider implements RepositoryProvider {
123123

124124
async hasReadAccess(user: User, owner: string, repo: string): Promise<boolean> {
125125
const api = await this.apiFactory.create(user);
126-
try {
127-
await api.repositories.get({ workspace: owner, repo_slug: repo });
128-
// we assume that if the current token is good to read the repository details,
129-
// then the repository is accessible
130-
return true;
131-
} catch (err) {
132-
console.warn({ userId: user.id }, "hasReadAccess error", err, { owner, repo });
133-
return false;
134-
}
126+
const result = await api.repositories.get({ workspace: owner, repo_slug: repo }).catch((e) => {
127+
console.warn({ userId: user.id }, "hasReadAccess error", { owner, repo, status: e.status });
128+
return null;
129+
});
130+
131+
// we assume that if the current token is good to read the repository details,
132+
// then the repository is accessible
133+
return result !== null;
135134
}
136135

137136
public async getCommitHistory(

0 commit comments

Comments
 (0)