Skip to content

Commit 3905d1c

Browse files
fix(selectors): gdrive and slack selectors inf loops (#1376)
* fix(selectors): gdrive and slack selectors inf loops * remove comment
1 parent cd084e8 commit 3905d1c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/channel-selector/components/slack-channel-selector.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,21 @@ export function SlackChannelSelector({
5858
body: JSON.stringify({ credential, workflowId }),
5959
})
6060

61-
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
61+
if (!res.ok) {
62+
const errorData = await res
63+
.json()
64+
.catch(() => ({ error: `HTTP error! status: ${res.status}` }))
65+
setError(errorData.error || `HTTP error! status: ${res.status}`)
66+
setChannels([])
67+
setInitialFetchDone(true)
68+
return
69+
}
6270

6371
const data = await res.json()
6472
if (data.error) {
6573
setError(data.error)
6674
setChannels([])
75+
setInitialFetchDone(true)
6776
} else {
6877
setChannels(data.channels)
6978
setInitialFetchDone(true)
@@ -72,6 +81,7 @@ export function SlackChannelSelector({
7281
if ((err as Error).name === 'AbortError') return
7382
setError((err as Error).message)
7483
setChannels([])
84+
setInitialFetchDone(true)
7585
} finally {
7686
setLoading(false)
7787
}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/file-selector/components/google-drive-picker.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export function GoogleDrivePicker({
100100
if (response.ok) {
101101
const data = await response.json()
102102
setCredentials(data.credentials)
103-
// Do not auto-select. Respect persisted credential via prop when provided.
103+
if (credentialId && !data.credentials.some((c: any) => c.id === credentialId)) {
104+
setSelectedCredentialId('')
105+
}
104106
}
105107
} catch (error) {
106108
logger.error('Error fetching credentials:', { error })
@@ -151,6 +153,14 @@ export function GoogleDrivePicker({
151153
onChange('')
152154
onFileInfoChange?.(null)
153155
}
156+
157+
if (response.status === 401) {
158+
logger.info('Credential unauthorized (401), clearing selection and prompting re-auth')
159+
setSelectedFileId('')
160+
onChange('')
161+
onFileInfoChange?.(null)
162+
setShowOAuthModal(true)
163+
}
154164
}
155165
return null
156166
} catch (error) {

0 commit comments

Comments
 (0)