Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
}
Comment on lines +103 to +105
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Type assertion to any should be avoided. Consider defining a proper type for the credential object.

Suggested change
if (credentialId && !data.credentials.some((c: any) => c.id === credentialId)) {
setSelectedCredentialId('')
}
if (credentialId && !data.credentials.some((c: Credential) => c.id === credentialId)) {
setSelectedCredentialId('')
}

Context Used: Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)

}
} catch (error) {
logger.error('Error fetching credentials:', { error })
Expand Down Expand Up @@ -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) {
Expand Down