From d70a5d427166f5729019cea4d3feadf9b1a4cdc7 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Fri, 13 Feb 2026 16:26:13 -0800 Subject: [PATCH] backfill improvements --- apps/sim/app/api/credentials/route.ts | 20 ++++++++++++++++++- .../credential-selector.tsx | 3 +++ .../components/tools/credential-selector.tsx | 3 +++ .../0155_nebulous_rocket_raccoon.sql | 3 ++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/apps/sim/app/api/credentials/route.ts b/apps/sim/app/api/credentials/route.ts index ca3cf084e..c0d71d173 100644 --- a/apps/sim/app/api/credentials/route.ts +++ b/apps/sim/app/api/credentials/route.ts @@ -184,7 +184,7 @@ export async function GET(request: NextRequest) { } if (lookupCredentialId) { - const [row] = await db + let [row] = await db .select({ id: credential.id, displayName: credential.displayName, @@ -195,6 +195,24 @@ export async function GET(request: NextRequest) { .where(and(eq(credential.id, lookupCredentialId), eq(credential.workspaceId, workspaceId))) .limit(1) + if (!row) { + ;[row] = await db + .select({ + id: credential.id, + displayName: credential.displayName, + type: credential.type, + providerId: credential.providerId, + }) + .from(credential) + .where( + and( + eq(credential.accountId, lookupCredentialId), + eq(credential.workspaceId, workspaceId) + ) + ) + .limit(1) + } + return NextResponse.json({ credential: row ?? null }) } diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx index 8b22f7b02..205de4311 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx @@ -133,6 +133,9 @@ export function CredentialSelector({ if (!response.ok || cancelled) return const data = await response.json() if (!cancelled && data.credential?.displayName) { + if (data.credential.id !== selectedId) { + setStoreValue(data.credential.id) + } setInaccessibleCredentialName(data.credential.displayName) } } catch { diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tools/credential-selector.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tools/credential-selector.tsx index e8acff028..8f701ec22 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tools/credential-selector.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tools/credential-selector.tsx @@ -109,6 +109,9 @@ export function ToolCredentialSelector({ if (!response.ok || cancelled) return const data = await response.json() if (!cancelled && data.credential?.displayName) { + if (data.credential.id !== selectedId) { + onChange(data.credential.id) + } setInaccessibleCredentialName(data.credential.displayName) } } catch { diff --git a/packages/db/migrations/0155_nebulous_rocket_raccoon.sql b/packages/db/migrations/0155_nebulous_rocket_raccoon.sql index 53d88c8a2..2e59d4de6 100644 --- a/packages/db/migrations/0155_nebulous_rocket_raccoon.sql +++ b/packages/db/migrations/0155_nebulous_rocket_raccoon.sql @@ -145,7 +145,7 @@ oauth_creds AS ( 'cred_' || md5(wua.workspace_id || ':' || a.id) AS id, wua.workspace_id, 'oauth'::"credential_type", - 'Default ' || COALESCE(pn.sname, a.provider_id) || ' Credential', + COALESCE(u.name, 'User') || '''s ' || COALESCE(pn.sname, a.provider_id), a.provider_id, a.id, a.user_id, @@ -153,6 +153,7 @@ oauth_creds AS ( now() FROM "account" a INNER JOIN workspace_user_access wua ON wua.user_id = a.user_id + INNER JOIN "user" u ON u.id = a.user_id LEFT JOIN provider_names pn ON pn.pid = a.provider_id WHERE a.provider_id != 'credential' ON CONFLICT DO NOTHING