fix(selectors): gdrive and slack selectors inf loops (#1376)

* fix(selectors): gdrive and slack selectors inf loops

* remove comment
This commit is contained in:
Vikhyath Mondreti
2025-09-18 11:40:36 -07:00
committed by GitHub
parent cd084e8236
commit 3905d1cb81
2 changed files with 22 additions and 2 deletions

View File

@@ -58,12 +58,21 @@ export function SlackChannelSelector({
body: JSON.stringify({ credential, workflowId }),
})
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
if (!res.ok) {
const errorData = await res
.json()
.catch(() => ({ error: `HTTP error! status: ${res.status}` }))
setError(errorData.error || `HTTP error! status: ${res.status}`)
setChannels([])
setInitialFetchDone(true)
return
}
const data = await res.json()
if (data.error) {
setError(data.error)
setChannels([])
setInitialFetchDone(true)
} else {
setChannels(data.channels)
setInitialFetchDone(true)
@@ -72,6 +81,7 @@ export function SlackChannelSelector({
if ((err as Error).name === 'AbortError') return
setError((err as Error).message)
setChannels([])
setInitialFetchDone(true)
} finally {
setLoading(false)
}

View File

@@ -100,7 +100,9 @@ export function GoogleDrivePicker({
if (response.ok) {
const data = await response.json()
setCredentials(data.credentials)
// Do not auto-select. Respect persisted credential via prop when provided.
if (credentialId && !data.credentials.some((c: any) => c.id === credentialId)) {
setSelectedCredentialId('')
}
}
} catch (error) {
logger.error('Error fetching credentials:', { error })
@@ -151,6 +153,14 @@ export function GoogleDrivePicker({
onChange('')
onFileInfoChange?.(null)
}
if (response.status === 401) {
logger.info('Credential unauthorized (401), clearing selection and prompting re-auth')
setSelectedFileId('')
onChange('')
onFileInfoChange?.(null)
setShowOAuthModal(true)
}
}
return null
} catch (error) {