Skip to content

Commit a985fac

Browse files
fix(worker): stop treating Bitbucket Cloud 410 as removed endpoint
1 parent e66cf46 commit a985fac

4 files changed

Lines changed: 2 additions & 30 deletions

File tree

packages/backend/src/ee/accountPermissionSyncer.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ describe('classifyPermissionSyncFailure', () => {
5050
test.each([
5151
['credential_rejected', 'upstream_credential_rejected'],
5252
['insufficient_scope', 'upstream_insufficient_scope'],
53-
['permission_endpoint_removed', 'permission_endpoint_removed'],
5453
] as const)('fails closed for a classified %s upstream failure', (kind, reason) => {
5554
expect(classifyPermissionSyncFailure(upstreamError(kind))).toEqual({
5655
action: 'clear_permissions',

packages/backend/src/ee/accountPermissionSyncer.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ type AccountPermissionSyncJob = {
3535
export type PermissionCleanupReason =
3636
| 'oauth_invalid_grant'
3737
| 'upstream_credential_rejected'
38-
| 'upstream_insufficient_scope'
39-
| 'permission_endpoint_removed';
38+
| 'upstream_insufficient_scope';
4039

4140
export type PermissionCleanupDecision =
4241
| {
@@ -51,7 +50,6 @@ const PERMISSION_CLEANUP_REASON_MESSAGES: Record<PermissionCleanupReason, string
5150
oauth_invalid_grant: 'OAuth invalid_grant',
5251
upstream_credential_rejected: 'upstream credential rejection',
5352
upstream_insufficient_scope: 'insufficient OAuth scope',
54-
permission_endpoint_removed: 'permission endpoint removed',
5553
};
5654

5755
export const classifyPermissionSyncFailure = (error: unknown): PermissionCleanupDecision => {
@@ -71,9 +69,6 @@ export const classifyPermissionSyncFailure = (error: unknown): PermissionCleanup
7169
if (error.kind === 'insufficient_scope') {
7270
return { action: 'clear_permissions', reason: 'upstream_insufficient_scope' };
7371
}
74-
if (error.kind === 'permission_endpoint_removed') {
75-
return { action: 'clear_permissions', reason: 'permission_endpoint_removed' };
76-
}
7772
}
7873

7974
return { action: 'preserve_permissions' };

packages/backend/src/ee/permissionSyncError.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,13 @@ describe('classifyPermissionSyncUpstreamError', () => {
5151
).kind).toBe('rate_limited');
5252
});
5353

54-
test('classifies Bitbucket Cloud 410 from the repository-list operation as a removed endpoint', () => {
54+
test('does not classify Bitbucket Cloud 410 as a removed permission endpoint', () => {
5555
const cause = Object.assign(new Error('Gone'), { status: 410 });
5656

5757
expect(classifyPermissionSyncUpstreamError(
5858
cause,
5959
'bitbucket-cloud',
6060
'list_accessible_repositories',
61-
).kind).toBe('permission_endpoint_removed');
62-
});
63-
64-
test('does not generalize HTTP 410 from another provider to a removed permission endpoint', () => {
65-
const cause = Object.assign(new Error('Gone'), { status: 410 });
66-
67-
expect(classifyPermissionSyncUpstreamError(
68-
cause,
69-
'github',
70-
'list_accessible_repositories',
7161
).kind).toBe('unknown');
7262
});
7363

packages/backend/src/ee/permissionSyncError.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export type PermissionSyncUpstreamErrorKind =
55
| 'credential_rejected'
66
| 'insufficient_scope'
77
| 'rate_limited'
8-
| 'permission_endpoint_removed'
98
| 'upstream_unavailable'
109
| 'forbidden'
1110
| 'unknown';
@@ -83,17 +82,6 @@ export const classifyPermissionSyncUpstreamError = (
8382
);
8483
}
8584

86-
if (
87-
status === 410 &&
88-
provider === 'bitbucket-cloud' &&
89-
operation === 'list_accessible_repositories'
90-
) {
91-
return new PermissionSyncUpstreamError(
92-
'The Bitbucket Cloud permission endpoint is no longer available.',
93-
{ kind: 'permission_endpoint_removed', provider, operation, status, cause: error },
94-
);
95-
}
96-
9785
if (
9886
status === 408 ||
9987
(status !== null && status >= 500 && status < 600) ||

0 commit comments

Comments
 (0)