Skip to content

Commit 7e42647

Browse files
committed
fix(slack): keep a throttled file download's retry reason
1 parent 1dfe378 commit 7e42647

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎apps/sim/lib/sim-search/live/slack.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,23 @@ describe('Slack file reads', () => {
117117
)
118118
expect(read.content).not.toContain('Reconnect')
119119
expect(read.content).toContain('Short preview')
120+
const throttled = fileClient({ mimetype: 'text/plain' }, async () => {
121+
throw new NativeSearchError(
122+
'rate_limited',
123+
'Provider rate limit reached. Try again later.',
124+
30,
125+
403
126+
)
127+
})
128+
expect((await readSlack(throttled, 'F123', undefined, 'file')).content).toContain(
129+
'Full text unavailable: Provider rate limit reached. Try again later.'
130+
)
131+
const relink = fileClient({ mimetype: 'text/plain' }, async () => {
132+
throw new NativeSearchError('reconnect', 'Reconnect this provider to restore its API host.')
133+
})
134+
expect((await readSlack(relink, 'F123', undefined, 'file')).content).toContain(
135+
'Full text unavailable: Reconnect this provider to restore its API host.'
136+
)
120137
for (const failure of [
121138
new Error('Too many redirects (max: 0)'),
122139
new DOMException('The operation timed out.', 'TimeoutError'),

‎apps/sim/lib/sim-search/live/slack.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ async function slackFileText(
420420
// files.info already accepted this token, so reconnecting would not change a refused file.
421421
return {
422422
unavailable:
423-
error.httpStatus === 401 || error.httpStatus === 403
423+
error.status === 'reconnect' && (error.httpStatus === 401 || error.httpStatus === 403)
424424
? "Slack did not serve this file's contents to your account. Open the source."
425425
: error.message,
426426
}

0 commit comments

Comments
 (0)