Skip to content

Commit 48c5fe5

Browse files
authored
Merge pull request #2532 from trycompai/fix/gcp-reconnect-flow
fix(cloud): identify legacy connections as old for reconnect
2 parents c1d2b7e + de1e1b2 commit 48c5fe5

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

apps/api/src/integration-platform/repositories/connection.repository.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ export class ConnectionRepository {
3939
organizationId: string,
4040
): Promise<IntegrationConnection | null> {
4141
return db.integrationConnection.findFirst({
42-
where: { providerId, organizationId },
42+
where: {
43+
providerId,
44+
organizationId,
45+
status: { not: 'disconnected' },
46+
},
4347
orderBy: { createdAt: 'desc' },
4448
include: {
4549
provider: true,

apps/app/src/lib/cloud-reconnect-policy.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ describe('requiresCloudReconnect', () => {
2525
).toBe(false);
2626
});
2727

28+
it('returns true for cloud connections created earlier on the rollout day', () => {
29+
expect(
30+
requiresCloudReconnect({
31+
providerId: 'gcp',
32+
createdAt: '2026-04-13T15:00:00.000Z',
33+
status: 'active',
34+
}),
35+
).toBe(true);
36+
});
37+
2838
it('returns false for cloud connections created after the cutoff date', () => {
2939
expect(
3040
requiresCloudReconnect({
@@ -54,4 +64,14 @@ describe('requiresCloudReconnect', () => {
5464
}),
5565
).toBe(false);
5666
});
67+
68+
it('returns true for legacy cloud connections', () => {
69+
expect(
70+
requiresCloudReconnect({
71+
providerId: 'aws',
72+
isLegacy: true,
73+
status: 'active',
74+
}),
75+
).toBe(true);
76+
});
5777
});

apps/app/src/lib/cloud-reconnect-policy.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const CLOUD_RECONNECT_PROVIDER_IDS = new Set(['aws', 'gcp', 'azure']);
44
* Connections created before this UTC timestamp require re-connection.
55
* This rollout date is fixed intentionally so the behavior is stable over time.
66
*/
7-
export const CLOUD_RECONNECT_CUTOFF_ISO_UTC = '2026-04-13T00:00:00.000Z';
8-
export const CLOUD_RECONNECT_CUTOFF_LABEL = 'April 13, 2026';
7+
export const CLOUD_RECONNECT_CUTOFF_ISO_UTC = '2026-04-13T18:16:52.000Z';
8+
export const CLOUD_RECONNECT_CUTOFF_LABEL = 'April 13, 2026 at 18:16 UTC';
99

1010
const CLOUD_RECONNECT_CUTOFF_MS = new Date(CLOUD_RECONNECT_CUTOFF_ISO_UTC).getTime();
1111

@@ -18,12 +18,14 @@ type ReconnectCandidate = {
1818

1919
export function requiresCloudReconnect(candidate: ReconnectCandidate): boolean {
2020
if (!CLOUD_RECONNECT_PROVIDER_IDS.has(candidate.providerId)) return false;
21-
if (candidate.isLegacy) return false;
2221

2322
if (candidate.status && candidate.status !== 'active' && candidate.status !== 'pending') {
2423
return false;
2524
}
2625

26+
// Legacy cloud connections come from the old integration table and should be re-added.
27+
if (candidate.isLegacy) return true;
28+
2729
if (!candidate.createdAt) return false;
2830

2931
const createdAt = new Date(candidate.createdAt);

0 commit comments

Comments
 (0)