Skip to content

Commit 58cdddc

Browse files
committed
chore(chat): annotate binary download fetch boundaries
1 parent a49b4f9 commit 58cdddc

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎apps/sim/app/(interfaces)/chat/components/message/components/file-download.tsx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DirectDownloadRequiredError extends Error {
2929

3030
async function fetchExternalFile(url: string): Promise<Response> {
3131
try {
32+
// boundary-raw-fetch: external binary download from an already validated HTTP URL
3233
return await fetch(url, { cache: 'no-store' })
3334
} catch {
3435
/** A navigation can download external files whose hosts do not allow CORS reads. */
@@ -95,10 +96,13 @@ async function triggerDownload(file: ChatFile): Promise<void> {
9596
if (!url) throw new Error('File has no download URL')
9697

9798
/** The same serve route as execution logs resolves current storage access on each click. */
98-
let response = hasStorageKey
99-
? // boundary-raw-fetch: binary file download through the authorized serve route
100-
await fetch(url, { cache: 'no-store' })
101-
: await fetchExternalFile(url)
99+
let response: Response
100+
if (hasStorageKey) {
101+
// boundary-raw-fetch: binary file download through the authorized serve route
102+
response = await fetch(url, { cache: 'no-store' })
103+
} else {
104+
response = await fetchExternalFile(url)
105+
}
102106
if (hasStorageKey && response.status === 401 && isSafeHttpUrl(file.url)) {
103107
await response.body?.cancel()
104108
/** Public chat visitors may only have the file access already delivered in the response. */

0 commit comments

Comments
 (0)