Skip to content

Commit f4feeba

Browse files
feedback
1 parent 3e38735 commit f4feeba

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/backend/src/bitbucket.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,20 @@ export const getUserPermissionsForServerRepo = async (
789789
export const isBitbucketServerUserAuthenticated = async (
790790
client: BitbucketClient,
791791
): Promise<boolean> => {
792-
const { error } = await client.apiClient.GET(`/rest/api/1.0/profile/recent/repos` as ServerGetRequestPath, {});
793-
return !error;
792+
try {
793+
const { error, response } = await client.apiClient.GET(`/rest/api/1.0/profile/recent/repos` as ServerGetRequestPath, {});
794+
if (error) {
795+
if (response.status === 401 || response.status === 403) {
796+
return false;
797+
}
798+
throw new Error(`Unexpected error when verifying Bitbucket Server authentication status: ${JSON.stringify(error)}`);
799+
}
800+
return true;
801+
} catch (e: any) {
802+
// Handle the case where openapi-fetch throws directly for auth errors
803+
if (e?.status === 401 || e?.status === 403) {
804+
return false;
805+
}
806+
throw e;
807+
}
794808
};

0 commit comments

Comments
 (0)